I was recently inspired ( once again ) by Kevin Hoyt at the Adobe MAX unconference which was put on by FITC and Influxus. Kevin gave a talk about physical computing which showed off a few examples of real world programming. This is where you use your developer know-how to interact with the world outside of the computer for a change. We had recently been talking at work about how we needed to build a robot, so the timing couldn’t have been better.
After recently upgrading to Snow Leopard I found that most of the getting started information was outdated for getting Flash to talk to the Arduino. I’ll show you what I did so I can hopefully save you some time. Less Googleing (is that a word?) and more tinkering.
What you need to get started
- Arduino micro controller board
- Ebay
- Maker Shed this is what I picked up
- I also use the Adafruit Proto Sheild which basically extends the power outs and grounds of your Arduino (among other useful things) which makes wiring up ideas much easier. I highly recommend getting one.
- Arduino IDE You will need this for uploading your initial firmware to the board. It also has the USB drivers needed for communication over a socket packaged with it on the disk image.
- Actionscript 3 development environment of some sort
- Flash 30 day trial
- Flex SDK is what I use with Textmate and Simon Gregory’s bundles
- Flash Builder
- AS3 Glue The library for interfacing between Flash and Arduino
- Firmata This is all that needs to be uploaded to your Arduino in order for AS3 Glue to do it’s magic
- TinkerProxy 2 OSX Download link the updated proxy for talking to your Arduino over a serial port connection
*I saved all of these into a new Arduino directory under Documents. I like having all of my related assets in the same directory.
Step By Step
Upload your Firmata to the Arduino
- First thing you want to do is plug in your Arduino to a USB port on your computer
- Install the Arduino IDE by dropping it into your Applications directory. Make sure you also install the drivers that are on the disk image. I made the mistake of not doing this the first time
- Fire up the Arduino IDE and explore the menu items. Most of the items we won’t be using yet since they apply mainly to development using processing. Since we will be doing the first few steps in pure AS3 we will only need to focus on uploading our Firmata
- Open the Firmata-2.1beta6 you downloaded and navigate to StandardFirmataV20.pde. Firmata-2.1beta6 > Firmata > examples > StandardFirmataV20 > StandardFirmataV2_0.pde
- Open StandardFirmataV2_0.pde in the Arduino IDE
- Upload Standard Firmata V2 to the Arduino board by clicking the upload button in the main IDE’s editor window

Configure TinkerProxy 2
- Go to the TinkerProxy 2 directory now. Notice that inside there are files referring to serproxy which is the outdated proxy program that TinkerProxy2 is based on. Because of this it works in the same exact way.
- Open serproxy.cfg configuration file and immediately save it as serproxy.osx.cfg. This is the name that TinkerProxy2 will look for and it keeps you from overwriting the default configuration by mistake.
- Go to the line that says # on a mac… You will need to add your Arduino’s USB device number here. To find it go back to the Arduino IDE and look under Tools > Serial Port and copy down the first cu.usbserial item you see in the list. The default is set to use tty but all of my reading says that on a mac the cu is more stable.

- Add your cu setting serial_device1=/dev/cu.usbserial-###### (whatever your aplha numeric setting is)
- Last thing is to change the commbaud under Default settings to 115200 like so commbaud=115200. I have also seen 9600 used but on my machine only 115200 worked.
- Save your configuration file. Remember to save it as serproxy.osx.cfg
- Right click on the serproxy.osx and choose open with Terminal. You might need to select other and browse to Applications > Utilities > Terminal. You should get a prompt that says “waiting for clients”

Import the AS3 Glue libraries
- Add the AS3 Glue libraries to your flash project.
- Basic code needed to get output is:
Flex
//FLEX STYLE
private function onCreationComplete(event:FlexEvent):void
{
arduino = new Arduino();
arduino.requestFirmwareVersion();
// when Arduino reboots, Firmata firmware sends its version to indicate startup
arduino.addEventListener(ArduinoEvent.FIRMWARE_VERSION, arduinoStartupHandler);
}
protected function arduinoStartupHandler(event:ArduinoEvent):void
{
Alert.show("Standard Firmata V" + arduino.getFirmwareVersion() + " Loaded");
//Set your pins here
}AS3
//AS3 STYLE
private function initialize(event:Event):void
{
arduino = new Arduino();
arduino.requestFirmwareVersion();
// when Arduino reboots, Firmata firmware sends its version to indicate startup
arduino.addEventListener(ArduinoEvent.FIRMWARE_VERSION, arduinoStartupHandler);
}
protected function arduinoStartupHandler(event:ArduinoEvent):void
{
//You should really try out Thunderbolt logger
trace("Standard Firmata V" + arduino.getFirmwareVersion() + " Loaded");
//Set your pins here
} - If you save and run this code you will see “Server thread launched” in the Proxy terminal window
- You are Ready to rock!
AS3 Glue allows you access to the Arduino’s outputs by exposing them as an AS3 API.
Example of setting up the RGB pins of an RGB LED
arduino.writeAnalogPin(redPin,0);
arduino.writeAnalogPin(greenPin,255);
arduino.writeAnalogPin(bluePin,255);Download an example project here
Flex 3 Project Files
*This is set up to build with ant
Here is a reference image for use with the example project. You will need to use a Proto Shield and a four pin RGB LED. I can add more instructions if there is interest.

To be continued… Next up, Building a robot with Flash and an Arduino

2 months later:
sick! thanks for the step-by-step guide. installing drivers now…
2 months later:
You made that easy. thanks now on to Step 2… then conquer the world
9 months later:
Can you please add the connection schematic you use. Great project.