This project is read-only.

Software Usage Concepts

Rhyduino is designed as a PC counterpart to a Firmata sketch running on a connected Arduino Duemilanove. Firmata is a protocol that defines the structure of messages being passed between devices. In our case, the devices are a PC and an Arduino, but the protocol doesn’t make any differentiation. Rhyduino will fully support the Firmata Protocol v2.1 but it’s not there yet.

Making the Connection

Before the exchange of messages can begin, the PC and Arduino need to have a physical connection between them, like with a USB cable. This is not strictly true – what’s important is that your computer sees your Arduino as a serial port.

The core Rhyduino object that you’ll use is Arduino. It’s safe to think of it as the software representation of your physical hardware. When you create an instance of the Arduino object you specify the connection settings (ex. serial port name, baud rate). These settings are immutable, so a single instance of an Arduino object can never be used to control more than one device. If you do not know the connection settings for your device, you can use the default constructor and it will find your Arduino for you. For performance reasons, it’s preferable to specify the connection settings and do not use the default constructor.

The Arduino object will not attempt to open a connection to the physical Arduino (via the serial port) by default. The Firmata protocol is very chatty, so it seemed better to allow the developer to decide explicitly when they’d like the messages to start flooding in. Connecting and disconnecting the Arduino object from the physical Arduino is accomplished with the Connect() and Disconnect() methods.


All messages sent from the physical Arduino are raised as events in the Arduino object. The event which gets raised depends on the data received. In most cases the Arduino object will know how to decode the message, resulting in event data contains both the decoded information and the raw stream of bytes that generated it. When the message type is unknown the UnknownMessageReceived event is fired and it contains only the raw message data.

Pin Modes

When writing code that runs on the Arduino directly, you are given the ability to set the input/output mode of digital pins. Firmata provides a way to do that as well, but takes it a step further by effectively asking you to be more specific. For example, if you intend to write pulse width modulated output to a digital pin then you’d need to specify that in advance.

In most cases, you’ll want to set the pin mode for each of the pins on the device as soon as you connect to it because you don’t know what state it will be in.

The Firmata protocol does not define a method for putting the Arduino’s analog pins into output mode.


If you’ve looked at the Firmata protocol then you know that it doesn’t provide a message that is used to request data for a specific hardware pin. Rather, you make a request to monitor a pin, or set of pins, and the physical Arduino notifies you of the value, regardless of any changes to it, on a specified interval. There is a message type to set the interval as well.

Notification data is only provided for pins that are in input mode.

At this point, Rhyduino does not make any effort to filter or smooth out the data reported by the Arduino. It is likely that an option to enable that will be added in future releases.


Sending data over a serial connection takes time, so messages describing the state of digital pins combine the values of multiple pins into a single value. Since digital pins can be either HIGH or LOW, reporting a pin only takes one bit. Therefore, digital data messages contain a variable for a port instead of pin. There are two digital ports, port 0 which contains data from pins 2-7, and port 1 which contains data from pins 8-13. Firmata depends on the use of the Arduino serial port so it doesn’t provide a way to address digital pins 0 and 1; those are the serial TX/RX pins.

Last edited Jun 6, 2010 at 11:39 PM by RhyMednick, version 2


No comments yet.