Arduino Flash communication AS3 – Messenger

Example how to setup serial communication between Flash and Arduino in combination with the Messenger library for Arduino. You can send whatever you want between Arduino and Flash (if you only want to receive data from inputs and set outputs it better to use Firmata / As3Glue combination). For receiving of data on the Arduino I’ll choose the Messenger library. It has some nice simple functions and gives you the opportunity to check if a string is fully received (a ‘carriage return’ is send by Flash at the end of a serial message in the SerialPort class) by Arduino. Of course you can write your own serial protocol. You can find some thoughts about it at the Todbot blog : Arduino serial protocol design patterns. You can send data to the serial port with the Serial.print() and Serial.println() commands. Included is the SerialPort class for Flash that makes it easy to send and receive serial data from/to the Arduino. I’ve modified the original (from so it supports start and stop characters. As a stop character ‘carriage return’ is used (‘\r’, or char(13)) that is send when you do Serial.println(); from Arduino. I advise using a start character (not used in the example below) as well, because sometimes (especially when sending on a high datarate) characters at the beginning if the string can get lost. The download contains and example_messenger.fla (CS3). Download : flash-arduino-as3-messenger

Step by step guide for Messenger library communication

  • Download the Messenger library and install it in your Arduino/libraries/ folder ( you can find it by default in your documents folder ). Restart Arduino if it was running.
  • Open basic_communication_old in my zip-file (basic_communication included in the Messenger examples has been changed).
    I’ve modified the old example in two ways. I’ve changed the serial speed to a baudrate of 57600, so you don’t have to change the Serproxy.cfg if you use it with Firmata as well and I have change the update interval to 40ms (instead of 20ms) for more stability.
  • Upload the Sketch to the Arduino.
  • Configure Serialproxy for your Arduino board and run it.
  • Open example_messenger.fla and run it.
  • If everything went fine you’ll see the led on pin 13 blinking and 6 balls, controlled by the analog inputs, moving on the screen.

Example_messenger code