Firmata Library

The Firmata library implements the Firmata protocol for communicating with software on the host
computer. This allows you to write custom firmware without having to create your own protocol and
objects for the programming environment that you are using.

Methods

begin();//start the librarybegin(long);//start the library and override the default baud ratebegin(Stream &s);// start the library using a [Stream](http://www.arduino.cc/en/Reference/Stream) other than Serial (eg Serial1 or EthernetClient)
printVersion();//send the protocol version to the host computer
blinkVersion()://blink the protocol version on the build in LED (typically pin 13)
printFirmwareVersion();//send the firmware name and version to the host computer
setFirmwareVersion(byte major,byte minor);//set the firmware name and version, using the sketch's filename, minus the '.ino'
setFirmwareNameAndVersion(const char*name,byte major,byte minor);//set both the name and version of the firmware

Sending Messages

sendAnalog(byte pin,int value);//send an analog message
sendDigitalPort(byte portNumber,int portData);//send an 8-bit port in a single digital message
sendString(const char* string);//send a string to the host computer
sendString(byte command,byte bytec,byte*bytev);//send a string to the host computer using a custom command type
sendSysex(byte command,byte bytec,byte* bytev);//send a command with an arbitrary array of byteswrite(byte c);//write a byte to the Stream

Receiving Messages

available();//check to see if there are any incoming messages in the buffer
processInput();//process incoming messages from the buffer, sending the data to any registered callback functions
attach(byte command, callbackFunction myFunction);//attach a function to an incoming message type
detach(byte command);//detach a function from an incoming message type

Utility methods

Callback Functions

In order to attach your function to a message type, your function must match the standard callback
function. There are currently three types of callback functions in Firmata: generic, string, and
sysex.