Firmata Device

Description

Interface to a microcontroller that supports the Firmata protocol.

Most Arduino boards and compatible devices (e.g. Teensy) can be configured to support the Firmata protocol via the Arduino Firmata library.

The device can be connected via a serial port or Bluetooth low energy (BLE). If both serial_port and bluetooth_local_name are omitted, MWorks looks for a single, connected serial device. If it finds one, it assumes it to be the desired Firmata device and attempts to connect.

Signature

iodevice/firmata

Optional Parameters

serial_port

Example

/dev/cu.usbmodem31

If the Firmata device is connected via a serial port, this parameter specifies the filesystem path that represents the serial port

bluetooth_local_name

Example

FIRMATA

If the Firmata device is connected via Bluetooth low energy, this parameter specifies its local name

data_interval

Example

5ms

Sampling interval for analog inputs. Must be a whole number of milliseconds.

connected

Variable in which to store connection state of the Firmata device (true if currently connected, false otherwise).

Normally, the device should be connected at all times. However, by monitoring the value of the specified variable, you can detect and respond to unexpected disconnections.

reconnect_interval

Default

0

Example

10s

If the Firmata device disconnects unexpectedly (e.g. due to power failure), and the value of this parameter is greater than zero, then the device will attempt to reconnect at this interval.

For example, if this parameter is set to 10s, then, upon disconnection, the device will wait for 10 seconds and then try to reconnect. If the reconnection attempt fails, the device will wait for another 10 seconds, then try again, and so on.

If the value of this parameter is zero, the device will never attempt to reconnect.

autostart

Default

NO

If YES, the device will start I/O automatically (as if by an implicit Start IO Device action) when the experiment starts running.

Note: Device I/O will always stop automatically when the experiment stops running, irrespective of this setting.

alt

Alternative device to use if this one fails to initialize (e.g. because the required hardware is not available). If #allowAltFailover is set to 0 or false, this parameter is ignored.

Placement

Allowed at top level:

Yes

Allowed parent:

Folder

Allowed children:

Firmata Analog Input Channel, Firmata Analog Output Channel, Firmata Digital Input Channel, Firmata Digital Input Pullup Channel, Firmata Digital Input Pulse Channel, Firmata Digital Output Channel, Firmata Digital Output Pulse Channel, Firmata Servo Channel, Firmata Word Output Channel