9.8 Arduino Serial Functions

9.8.1 @device/delete

: delete (dev)

Free resources of a device object.

Inputs

dev - object to free

See also: device.

9.8.2 @device/device

: dev = device (ar, 'I2CAddress', address)
: dev = device (ar, 'SPIChipSelectPin', pin)
: dev = device (ar, 'Serial', serialid)
: dev = device (..., propname, propvalue)

Create an i2c, spi or serial object to communicate on a connected arduino.

Inputs

ar - connected arduino object

propname, propvalue - property name/value pair for values to pass to devices.

A property of ’i2caddress’, ’spichipselectpin’ or ’serial’ must be specified to denote the device type to create.

i2caddress - address to use for device on I2C bus.

pin - pin to use for device SPI chip select.

serialid - Serial port id to use

Additional properties can also be specified for the device object

Currently known input I2C properties values:

bus

bus number (when arduino board supports multiple I2C buses) with value of 0 or 1.

noprobe

Do not probe the existence of device on creation if set to 1 (default 0)

bitrate

bit rate speed in Mbs - default 100000

Currently known input SPI properties values:

bitrate

bit rate speed in Mbs

bitorder

’msbfirst’ or ’lsbfirst’

spimode

SPI mode 0 - 3.

Currently known input Serial properties values:

baudrate

baudrate value (default 9600)

databits

number of databits (5,6,7,8) (default 8)

stopbits

number of stopbits (1,2) (default 1)

parity

parity of device (’odd’,’even’,’none’) (default ’none’)

Outputs

dev - new created device object.

Properties

The object has the following public properties:

parent

The parent (arduino) for this device

interface

The interface type for this device ("SPI" or "I2C" or "Serial")

In addition, depending on type, the object will have these properties:

I2C Properties

The object has the following public properties:

bus

bus used for created object

i2caddress

I2C address set for object

sclpin

the SCL pin of the device

sdapin

the SDA pin of the device

bitrate

bit rate for the i2c clock

SPI Properties

The object has the following public properties:

spimode

mode used for created object

bitrate

Bitrate set for object

bitorder

Bitorder set for object

spichipselectpin

Pin used for chipselect

mosipin

Pin used for mosi

misopin

Pin used for miso

sckpin

Pin used for sckpin

Serial Properties

The object has the following public properties:

id

serial port id

baudrate

baudrate

databits

number of databits (5,6,7,8)

stopbits

number of stopbits (1,2)

parity

parity of device (’odd’,’even’,’none’)

See also: arduino, i2cdev, spidev.

9.8.3 @device/display

: display (dev)

Display device object.

Inputs

dev - device object to display

See also: device.

9.8.4 @device/flush

: data = flush (dev)
: data = flush (dev, "input")
: data = flush (dev, "output")

Flush the serial port buffers

Inputs

dev - connected serial device opened using device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs

None

See also: arduino, device, read.

9.8.5 @device/read

: data = read (dev, numbytes)
: data = read (dev, numbytes, precision)

Read a specified number of bytes from a i2c or serial device object using optional precision for bytesize.

Inputs

dev - connected i2c or serial device opened using device

numbytes - number of bytes to read.

precision - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Outputs

data - data read from the device

See also: arduino, device.

9.8.6 @device/subsref

: val = subsref (dev, sub)

subref for device

See also: device.

9.8.7 @device/write

: write (dev, datain)
: write (dev, datain, precision)

Write data to a I2C or serial device object using optional precision for the data byte used for the data.

Inputs

dev - connected i2c or serial device opened using device

datain - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

precision - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

See also: arduino, device, read.


Next: Arduino Device Functions, Previous: Arduino SPI Functions, Up: Function Reference   [Contents][Index]