• It’s not working! What should I do?

    Start with these steps.

    • Pay attention to the debug outputs
    •  You may need to set RebootDelay to a longer duration for some boards to give them time to reset (Leonardo for instance)
    •  Check the Arduino IDE to make sure you have the right port name (and generally make sure you can communicate with the board)
    •  Another program could be using the port and may not want to give it: kill everything, unplug device, replug it, try again
  • I seem to be connected but I cant even blink an LED! What did I do wrong?

    1. Verify that you used Setup correctly to set pinMode to output

    2. Check that an LED is actually wired properly to that pin (if your not using the boards built in test LED)

    3. Check the polarity and the presence of a load resistor. Then check the output with a voltmeter.

    4. If that fails, close unity, and try to get it working in the Arduino IDE

    5. If arduino’s blink sketch works, re-upload StandardFirmata, then use the firmata test console available at http://www.firmata.org to try blinking the LED

    6. If that works, then try the Uniduino Test Panel.

    7. If that all works, the problem is not with the board or with firmata, so the blink tutorial should work. If not, something is seriously wrong — contact us!

  • MAC OSX: I’m seeing “Warning: SerialPort support not installed” what should I do?

    1. using Terminal, double check that libMonoPosixHelper.dylib is in ~/lib/

    2. if it is, and still isnt working, run:

    $ sudo cp libMonoPosixHelper.dylib /usr/lib/

    3. restart Unity

    4. if this still isnt working, contact us immediately!

  • “Connected but waiting for Firmata protocol version” error

    Set baud rate of the com3 device (the arduino) and the Uniduino prefab to 57600.

Script Reference

  • Arduino( )
    Arduino ()

    Default constructor, convenient for when embedded in a MonoBehavior with different construction behavior

    /* Construct with explicit parameters */
    Arduino ( string serialPortName, Int32 baudRate, bool autoStart, int delay ) 	
    /* Creates an instance of the Arduino object, based on a user-specified serial port. 
    Assumes default values for baud rate (115200) and reboot delay (8 seconds) and
    automatically opens the specified serial connection. */
    Arduino ( string serialPortName	) 
    /* Creates an instance of the Arduino object, based on user-specified serial port and baud rate. 
    Assumes default value for reboot delay (8 seconds). and automatically opens the specified 
    serial connection. */
    Arduino ( string serialPortName, Int32 baudRate )

    serialPortName String specifying the name of the serial port. eg COM4
    baudRate The baud rate of the communication. Note that the default firmata firmware sketches communicate at 57600 by default.
    autoStart Determines whether the serial port should be opened automatically. use the Open() method to open the connection manually.
    delay Time delay that may be required to allow some arduino models to reboot after opening a serial connection. The delay will only activate when autoStart is true.

  • Setup ( )
    void Arduino.Setup ( Action action )

    Instruct Uniduino to execute an action only after arduino is connected and not before. Use for one-time setup of the board such as setting pinModes and reporting states.

    // set pin 13 to output
    void Start( ) {
    void configurePins( ) {
        arduino.pinMode(13, PinMode.OUTPUT);
  • Connect ( )
    void Arduino.Connect()

    Connect to the Arduino and run any Setup actions you have requested. Called for you if AutoStart is enabled.

  • Disconnect ( )
    void Disconnect()

    Disconnect from the Arduino.

  • analogWrite( )
    void analogWrite(int pin, int value)

    Write to an analog pin using Pulse-width modulation (PWM).

    pin Analog output pin.
    value PWM frequency from 0 (always off) to 255 (always on).

  • digitalWrite( )
    void digitalWrite( int pin, int value )

    Write to a digital pin that has been toggled to output mode with pinMode() method.

    pin The digital pin to write to.
    value Value either Arduino.LOW or Arduino.HIGH.

  • reportVersion( )
    void reportVersion()

    Request the device to report the version of the loaded Firmata firmware. The VersionDataReceived event is fired when version data is received.

  • reportAnalog( )
    void reportAnalog ( int pin, byte enable )

    Reports the analog.

    pin Pin number in analog numbering scheme.
    enable Enable (0 or 1)

  • reportDigital( )
    void reportDigital ( byte port, byte enable )

    Enable/disable reporting of each port. When a port is enabled, the default Firmata firmware will continuously scan each digital input on the port and send updated values if any change. Refer to arduino docs for discussion on ports and their mapping.

    port Port number.
    enable Enable (0 or 1)

  • pinMode( )
    void pinMode ( int pin, PinMode mode )

    Sets the mode of the specified pin (INPUT or OUTPUT).

    pin The arduino pin.

  • analogRead( )
    int analogRead ( int pin )

    Returns the last known state of the analog pin.

    pin The arduino analog input pin.

    A value representing the analog value between 0 (0V) and 1023 (5V).

  • digitalRead ( )
    int digitalRead (int pin)

    Returns the last known state of the digital pin.

    pin  The Arduino digital input pin.

    Arduino.HIGH or Arduino.LOW

  • queryCapabilities( )
    void queryCapabilities()

    Request firmware to report pin capabilities.

  • CapabilitiesReceivedEventHandler( )
    delegate void CapabilitiesReceivedEventHandler( List< Pin > pins )

    Capabilities received event handler. Fired when pin capabilities are received from the device. Request pin capabilities with a call to queryCapabilities

  • VersionDataReceivedEventHandler( )
    delegate void VersionDataReceivedEventHandler(int majorVersion, int minorVersion)

    Version data received event handler. Fired when version data is received. Request protocol version data with a call to reportVersion

  • AnalogDataReceivedEventHandler( )
    delegate void AnalogDataReceivedEventHandler(int pin, int value)

    Analog data received event handler. Fired when new analog data is received from the device This event will only be fired for analog pins for which reporting has been enabled with reportAnalog

  • DigitalDataReceivedEventHandler( )
    delegate void DigitalDataReceivedEventHandler ( int portNumber, int portData )

    Digital data received event handler. Fired when new digital data is received from the device. This event will only be fired for ports for which reporting has been enabled with reportDigital.

    portNumber port number
    portData A bit vector encoding the current value of all input pins on the port.

Uniduino Test Panel

  • Uniduino Test Panel

    The Uniduino Test Panel provides a visual interface to the I/O states of each pin. It is essentially the same as the Firmata viewer tool on firmata.org but implemented fully in Unity for your convenience and also to serve as complete example code.

    If everything is working correctly, you should be able to connect and see a screen that looks like this:

    uniduino console screen

    NOTE: what you see here will vary depending on which Arduino board your using

    The pin list shows the current input reading (i.e. what would be returned from a call to analogRead or digitalRead), the output value (high/low for digital modes as would be set with digitalWrite or a slider representing the value from 0 to 255 that would be passed to a call to analogWrite when in PWM mode.), the pin mode, and the reporting state of each pin.

    The Firmata sketch attempts to report accurate pin capabilities, but this is not always available or up to date. Some boards report more modes for a pin than they actually support. If every mode is reported as supported for every pin, be suspicious. Refer to your boards own documentation to determine what modes are actually supported. Occasionally there are transmission glitches with the pin capability data itself, so if you are seeing weird modes listed or missing pins, hit the Query button again.

    The pin modes currently useable by Uniduino are INPUT OUTPUT, ANALOG, and PWM. Refer to arduino documentation for full explanations of each mode.

    Reporting states are extra states that firmata uses to filter what data to send back to the Uniduino client. When a pin is active for digital reporting, any change in its digital value triggers an immediate message to the client. When a pin is active for analog reporting, its values are reported continuously at a set sampling interval. (This interval is configurable, but we haven’t exposed it yet via our Firmata client. Currently the easiest way is to modify the hardcoded value in the StandardFirmata sketch).


  • If the Uniduino Test Panel isn’t working properly.

    Some simple things to try.

    – Press Disconnect, unplug the arduino, wait a few seconds, plug it back in, and press Connect again

    – Disconnect, press the Guess button to try to guess the port name, and try to Connect again. Usually you can get the correct port name from the arduino IDE itself, from the Device Manager in windows, or by inspecting the results of ‘ls /dev/ | grep tty’ in the Terminal on OSX.

    If everything looks ok so far, here are some basic hardware tests:

    – Most Arduinos have an LED connected to pin 13 by default. Set pin 13 to OUTPUT and click the low/high button to watch it toggle on and off.

    – Wire a potentiometer to one of the analog pins, set the mode to ANALOG, make sure Reporting/Analog is enabled (green), and twist the knob to watch the analog reading change.

    – Wire an LED and a resistor to a pin that supports PWM, set the pin to PWM and move the slider. The LED brightness should change accordingly.