Arduino Flash communication AS3 – Firmata

Update: The most recent version doesn’t use As3Glue anymore, but improved code. Documentation is included in the zip-file.

I’ve created a Flash monitor application with As3Glue to make it easier to start with Flash Arduino communication.

Glue is an ActionScript 3.0 library that enables communication between Flash and Arduino boards with Firmata. Since Flash cannot interface the serial port directly we’ll use Serialproxy in between. Serialproxy converts incoming serial data the XMLsocket data.

The monitor is useful to check if all the connections are working good. You can monitor directly all the sensors and actuators connected to your Arduino board.

The example code file is a start point to program your own things controlled by Arduino. Its support the normal Arduino board and the Arduino Mega.

Included files :

The Firmata library is included with Arduino itself. Make sure you use Arduino 018 or higher, because the Firmata library included in version 017 is not stable.

  • Update (12-05-10, v1.3): I’ve updated the code for the support of two servo motors (pin 9 and pin 10).
  • Update (17-09-10, v1.5): Program example simplified. Now executables included and hosted on Google code.
  • Update (11-02-11, v1.6): Program example included state-change example. Arduino UNO connection example in serialproxy.cfg.
  • Update (20-10-11, v2.0): Included support for the Arduino Mega in the program example. Thanks to Mochammad Effendi.
  • Update (03-04-14): New version. Doesn’t use as3glue at the Flash side anymore but a new implementation as was used our classes.

Download the zip-file:

106 thoughts on “Arduino Flash communication AS3 – Firmata”

  1. Hi Kasper,

    I just discovered this little tool you made. This is great stuff! I will use it with my students to troubleshoot their projects. Thanks for making it available to the community.


  2. Hi Kasper, thanks for the amazing video tutorial and code. It has been really helpful.

    I wonder whether this code can be used with the USB Host shield from circuits@home ( I’m trying to use a playstation3 sixaxis controller for its accelerometer and gyro inputs but don’t seem to be having much luck. I’m guessing maybe because the hostshield has its own custom library, but when I follow your tutorial the standalone montior shows successfully connected but the graph stays more or less static and I don’t seem to be able to receive any data from the controller. Is there any way to use as3glue in this way? Or is there something I’m missing?

    Many thanks,


  3. Hi David,

    I think its will be difficult since you don’t work with the normal I/O pins from the Arduino. Of course you can send serial data ( with serial.print ) to Flash. I have a AS3 script that listens to normal serial data send by the Arduino. Didn’t have time yet to publish it here. Send me a mail and I will reply it to you.

  4. Hi Jean-Phillippe,

    Thanks for the remarks and the Serialproxy 0.1.4 version.

    The ‘advanced settings’ wouldn’t open anymore with right-click on my mac, so I thought it wasn’t supported anymore. Also because I was reading that Flash 9 and beyond have more restricted security settings and that you’ll need a ‘socket policy file server’.

    See :

    Another disadvantage with the security settings preferences is that you’ll need an internet connection to change them.

  5. Hello,

    Great tool! But I was wondering how to control a servo with Glue. Using a PWM port makes the servo behave very strange and unpredictable so I was wondering if it’s possible to use the servo library from Arduino. Or maybe there is another way to do it :)

    Many thanks,

  6. Hi Jim,

    I think that standardFirmata has servo support. As3glue supports 2 servo motors.

    This you have to put in the ‘onReceiveFirmware function’ :

    arduino.setupServo(pin,angle): Initialize servo timer routines on a pin. Pin must be 9 or 10 in the current implementation.
    between 0 and 180.

    From the timerEvent function you can use :

    arduino.writeAnalogPin(pin, angle): Write a servo angle (in degrees) to an output pin. value has to be a number between 0 and 180. Pin must have been initialized with setupServo() before.

    For more info see the As3Glue reference :

    Let me know if it works, maybe I can modify my example files for servo support.

  7. I managed to get it to work, thanks! I imported the ArduinoWithServo file which worked great combined with the code you posted.

  8. Great tutorial. I am using Arduino with 3 Potentiometers to talk to Flash for an interactive media project for my thesis. I was thinking of trying out ArduinoProcessingFlash with processing as the middleware from Kan Yan Li,

    Do you know any advantage to this? I don’t think I need to use Processing really except for displaying a video onscreen as Arduino’s pot. inputs trigger/respond to events in Flash/AS3.
    Is it more robust to just cut out Processing (the middleware)?


  9. Hi Vincent,

    I couldn’t open that website, but I think its using Processing for the serial to Xmlsocket conversion. In my version Serialproxy is used for that.

    You need the middleware since Flash cannot communicate directly with the serialport.

    Another option as middleware could be

    I prefer Serialproxy for most of my projects and teaching, since its the most basic option.


  10. Hello kasperkamperman, where can I get “as3glue_standalone_monitor.fla” and “as3glue_program-example.fla” ? Thanks for all :)

  11. Hi kasperkamperman.

    I wired a push button switch.
    I’m monitoring each of the pins from 2 – 13 as digitalIn.
    The monitor displays two inputs at the same time when my push button is connected to one pin only.
    For example: Push button sends the signal to pin 8 and the monitor displays that 7 and 8 are being pressed.

    ¿Why is this?
    I already tried this with two different Arduinos.

  12. I was using tty instead of cu on my serial port. I don’t know what’s the difference but apparently it was that what caused the false positives.

    Although I still get some when the push button bounces.

  13. Since there is nothing connected to pin 7 (no ground, no 5V) it can change due electrical noise. If you watch the analog inputs you see the same effect. Change one input, and they probably change all.

    The solution is to wire the unused pins to ground. However, that would be just for the looks. If you didn’t connect something to pin 7, you don’t want to listen to it in Flash. It doesn’t matter that it changes, if you don’t use the values of that pin.

  14. Hiya,
    thanks for the reply.
    Yes that site was in downtime last I checked. But I figured out what I wanted to make/do. So I went with Tinkerproxy and as3glue as you recommeneded.
    Having quite a lot of fun with making the Flash App and dynamic filters from pixel bender.

    Best regards

  15. Hi Kasper,
    first of all thanks for this tutorial. It is very easy and good explained.
    I have a problem with my Arduino Mega. I don´t get no response. I followed all your steps. I loaded Firmata to the board. Then i configurated the serproxy as in your discription. After starting the flash program, there are no errors displayed. But on the board there is no signal on pin 13.
    After following your steps a couple of times i took a duemilanove Board and it works perfectly.
    Do you have any idea why does´nt work the Arduino Mega Board?
    Thanks for your answer!

  16. I agree with you Kadri. I also have trouble about that. In addition, when I pressed reset button there is no anything change, the loaded program still works. what a difference could be between mega and duemilanove?

  17. I don’t have time to dive into it now. I think you’ll have to search if Firmata supports the Arduino Mega in the same way as the duemilanove. I think not, because it has different outputs.

  18. hi, thank you for your tutorial. i am a beginner and have the following issue:

    serproxy is running and telling me “server thread launched” and “server(6) – thread started” so i guess i did the configuration of serproxy right.

    when i start the standalone monitor and i want to turn pin 13 on, i have to press several times until finally the led is on. if i want to turn it off i also have to press several times until it does what i want.

    do you have any idea what my problem is? pleas help! thanx

  19. I don’t know which Arduino board you have, but with the Arduino Uno I’ve encountered the same issues. I think it has to do something with the new serial chip. If you can get an Arduino Duemilanove or older I would go for that.

    I posted a topic in the Arduino forum about this as well: Uno Firmata as3glue

  20. hi. i’m confused and can’t find any documentation.
    i have arduino with hmc6352 compass sensor, i can see the degrees oanduino monitorbut in flash i don’t see anything, even in your monitor, any help around?

  21. Any time to work out all the digital ins and outs for the Mega? Or maybe post some hints to look at to figure it out? I am able to successfully test all inputs and outputs with the Arduino 0021 StandardFirmata and program. Any help would be appreciated.

  22. Hi I have successfully got this to work thanks.

    If I wanted to read an RFID cards through an Arduino reader through Flash do you have any suggestions?

  23. Hi,

    thanx for the cool library.

    I’m trying to connect 4 or more servos to the Arduino.
    The current AS3Glue can only work with servos on pins 9 & 10.

    Where should I be looking at to tweak this to >2 servos?
    AS3Glue? SerProxy? Firmata?

    Thank you.

  24. Hi Lex,

    I think you should look if Firmata supports it. If Firmata supports more servo’s, you could rewrite as3glue.

    Serialproxy is just to convert serialport messages to net socket.

    You can do it without Firmata easier I think. Since Arduino the Arduino servo library supports 12 servo’s for sure. Just send a serial string with 4 servo positions like this for example: 180, 90, 0, 90

    To do serial communication with your own “protocol” check my other post:

  25. Hi,

    I’ll give you my warmest congratulations, the application is very useful and works very well.
    I was looking for something like this for a long time for my project with Arduino. Congratulations!

  26. Connection with Serproxy established. Wait one moment.
    …. after that noting come.. i wait for long time….. can you please tell me what is the problem…
    please send me email on [email protected]

  27. You watched the tutorial, read the readme.rtf file. Probably serproxy doesn’t see your Arduino. You’ve uploaded Firmata and edited the .cfg file with you serialport name?

  28. Wonderful app, I have loved flash since Flash 5…this is great for testing. I had this working yesterday, made some changes to get the Chambers Blink sketch to work, which it does, went back to yours because it is so much better, and set the .cfg for proxy apparently correct, and it hangs on the connection…I can go right back to another flash program and connect, what small thing am I missing here…I really want to use this…thanks so much.

  29. Great that you’ve could solve it. A colleague of me is developing a new version, with even more stability with unplugging, plugging and error handling. Will publish that if its ready.

  30. I’m sorry to bother you but I am having a problem getting Flash to hear my RFID reader.  I have tried almost all of your Flash Arduino toolkits and I just can’t get any of them to hear the serial output from the RFID reader (Parallax USB RFID reader).

    I have been able to verify that the Arduino script is sending the RFID tag ID.  I get the data on the Arduino serial monitor.  It looks great.  But . . . Flash never gets the data.  I have put trace statements in all of the pertinent functions and the onReceiveData funtions never go off.  I never see a trace from them.

    I am using a Mega 2560 board and have tried adjusting the pinouts but still no go.  Again, the RFID reader code is working and the Serial.Print or Serial.Println statements are outputing to the serial monitor.  Serproxy is working, it sends data to your GUI.  I don’t know what I am doing wrong.  Any help would really be appreciated.  Thank you in advance.

  31. Well, AS3Glue only works with Firmata. So thats the code you’ll have to use on the Arduino. Firmata is like a sensorbox. 

    In this case you work other software on the Arduino, that sends serial data. 

    Check out my other post:

    If you want to read serial commands in Flash.

  32. Thank you very much for your quick reply.  I have also tried the Messenger toolkit and in that case, the trace statement in the onArduinoData function never fires (it never shows up in the output window) even though I have inserted a Serial.Print statement in the arduino code to make sure something is being sent.

    Is there some special way I need to send the serial information (I am just sending a test string) or something I need to do to force a send over Serproxy to Flash?  Thank you.

  33. Try to check if you Serproxy configuration is good. You could test this with the Firmata As3Glue bundle. Remember you’ll always need Serproxy in order to let Flash/Arduino communicate.

    A serial.print should work good, but pay attention to the Baudrate (the number after Serial.begin( )), this should be the same as in the Serproxy program (for As3Glue configured as 57600).

  34. Yes.  Serproxy seems to be OK.  I can confirm the connection and I have been able to trace data sent TO the Arduino from Flash, so I think it is working.  I am using 57600 and I get, what seem to be, normal messages in the Serproxy window about waiting . . . connecting . . . and disconnecting when I shut down the Flash app.

    I suspected Serproxy but it seems to be communicating from Flash to the Arduino.  Is there some other test I should do to verify that Serproxy is not blocking data from Arduino to Flash?  Thank you.

  35. The only thing I can think of is the test the As3Glue bundle with Firmata. If thats working, then you know for sure that 2-way communication is working. Its not so much work, just upload standardfirmata to your Arduino (included with Arduino examples) and fire up the standalone monitor application.

  36. Sorry, I forgot to mention that I have run the AS3Glue standalone application successfully.  I don’t have all of the sensors hooked up but the monitor shows the wave graphs moving and the bar heights change over time.  It looks like everything is working in the monitor (without real sensors connected).

    So, I think Serproxy is working.  I have tried to use Serial.print(“Hello world!) as a test but it doesn’t seem to cause any activity in Flash.  Thank you.

  37. I have been able to get data to flow from Arduino to Flash.  The change I made was to remark out the code that enabled and set up the serial port for the RFID reader.  I will need to put that code back in to make the system work.  I am using Serial2 as the serial port for the RFID and leaving Serial available for Serproxy.

    Should I be able to use both serial ports (Serial2 communicating the RFID data to the Arduino and Serial to communicate with Flash via Serproxy)?

    Do you think I need some kind of special code to allow them both to work?  Thank you.

  38. OK.  I think I have the Arduino communicating with Flash using your code.  It looks like the problem was that I was calling sendInputsToFlash AND calling Serial.print from inside the Loop.  I removed the reference to sendInputsToFlash and the data started to flow.

    I am using a Mega 2560 board.  Unlike the Uno, it has four physical serial ports addressed as Serial (the standard pins 0 and 1), Serial1 (pins 18, 19), Serial2 (pins 16, 17) and Serial3 (pins 14, 15).  It is allowing me to call the setup for each port separately like this:

         Serial.begin(57600);  // start Serproxy serial port (USB connection to PC)
         Serial2.begin(2400);  // start RFID serial port (in this case, connected to RFID reader)
    Now, I just have to work out displaying and/or using the RFID data to trigger some action in Flash.
    Thank you very, very much for responding and helping with this problem.  I really appreciate it.

  39. hey im using a windows computer when i want to upload firmata into my arduino board i have learn that we have to choose a port 3 or 7 for windows computer but in my case i cant seem to find port 3 or 7. theres only port 1. any ideas? 

  40. Did you install also the drivers for your board.
    Did you try to upload an example sketch (blink) for example and checked if that worked?

    Please read the troubleshouting section on first, because I think your problem is not firmata related.

  41. Hey. Thanks for the reply. The problem have been solve. thankyou. But after i did everything the serproxy showed me that refused connection. i already disable the firewall. Could it be the code? But the code i am using is the as3glue code. 

  42. Please configure it well. I suppose you did something wrong in the .cfg file, so please read carefully an decomment the right things.
    This is not related to the as3glue code yet.

  43. Hey, i’m using arduino BT, currently every thing is alright, but whenever i test it on the standalone_monitor, the socket closes immediately. I will see connection refused on the serproxy.cfg even though configuration of ports and baudrate are same as firmata.. any ideas??

    # Example configuration file for serproxy – PC Version# For use with Firmata 2.0# Note: in this example, Arduino uses COM3 – this is reflected in the line comm_ports=3 #and net_port3=5331 below. # If your board is on COM4, you’d have to change those lines to #comm_ports=4andnet_port4=5331. # Do not Transform newlines coming from the serial port into nilsnewlines_to_nils=false# Comm ports usedcomm_ports=7net_port7=5331# Default settingscomm_baud=57600comm_databits=8comm_stopbits=1comm_parity=none# Idle time out in secondstimeout=300

  44. You removed the comment symbols (#) in front of the lines?
    You connected by Bluetooth or with the serial port? I don’t have experience or an idea if it works by Bluetooth. Check out the maximum baudrate for bluetooth, this can be different. 

  45. yup. i connected by bluetooth. had no idea how to check the baudrate for bluetooth at all.. first time doing flash projects with arduino..

  46. Well read the documentation. Arduino has pretty good hardware descriptions on their site. If this is your first experiment I would suggest to try it first with an USB cable over the serial connection. Then make the step to Bluetooth. 

  47. Alright. I settled the baud rate for bluetooth etc to 56700 as stated in firmata already. But still facing the error of socket error :, i’ve checked the localhost in my computer already and they both matches.. however serproxy wouldn’t work..

  48. hi, i have a problem with communicate between arduino and AS3

    my arduino ‘Leonardo’

    on win7 64bit, test the communicate with flash, but every time when i compiler my AS3 Glue the bundle ,It only show as this picture:

    “Connection with Serproxy established. Wait one moment.”

    What’s happend with this?  if in Mac OSX is’t all ok but not work out in windows.

    Could you please help me with this problem?  thank you.

  49. I don’t work on windows so I can’t reproduce it now. Do you get some information in the Serproxy application?

    You say it works with OSX so there is no problem that its the Leonardo? Maybe you have to install drivers on Windows? Did you try to upload Firmata with Arduino on the windows PC.

  50. sir I try 
    upload Firmata with Arduino and install drivers on the windows PC.But,Problems still exist

  51. Hi! I am new to arduino n all this, so please bare with me :) I am making an interactive game for my final project, using arduino + flash AS3. I already managed to use serproxy to communicate with my arduino uno, and i can see from the monitor that when i turn pin13 on the LED lights. But from there i have no clue on how this act. works! May i please request a for dummies tutorial on how it works afterwards?


  52. I am using windows xp and arduino uno. I also did the correct changes in serproxyCFG file but
    when i open serproxy it said
     Connection with Serproxy established. Wait one moment….. after that noting come.. i wait for long time…..
    it’s also not ask for incoming network connection.

  53. Hi All,  I’m trying to get a reading from my SR04 sensor into Flash. How do I do that as3glue.
    thank you

  54. Hi. Not sure if anyone has already asked.. Not sure you covered it in your video, is there a way to wrap the flash and SerProxy together and auto detect the USB port/IO so that this can be run as a standalone final application?

  55. there is a sensor to calculate distance that matches the as3glue?
    thanks again

  56. It works! however I cannot open the source files; Unexpected file format.
    I have Flash 8, could that be the reason?

  57. Hi, i don’t know what is wrong, my arduino is 0022 version and i have a flash cs5, i did every thing and when i open as3glue_standalone_monitor in flash it says “connection stablished. wait” and nothing happens

  58. Hi!, how can I do to use the pulseIn function in AS3 with Firmata? I need to read the information of an ultrasonic sensor HC-SR04 in my actionscript file. I hope you can help me. Thanks!

  59. A collegue of my is busy with a major rewrite to support more Firmata possibilities in AS3.
    I’ll ask if this is supported, maybe I can send you the code so you can test this.

  60. Wonderfull! Do you know if does exist another way to read the information send from arudino serial intro flash?

  61. Good day, wonderful site and information!

    Any updated info on pulseIn? Trying to read 20 steady pulses at 50ms intervals. I know the hardware that is sending the pulses is spot on, and I know that the flash timer isn’t perfect, so its hard to capture each and every pulse that comes in. Or even some idea on a buffer to ensure that each pulse is read.


  62. Also, this might be a noob question, but I have 3 digital inputs one pin (2), (7) and (8). I notice when I read pin (2), pin (7) gets triggered as well, and vice versa, when I read pin (7), pin (2) gets read when they are supposed to have separate functions / buttons.

    Is this because they are on the same I/O block? This was also the case when I just had 2 inputs, one on pin (5) and one on pin (7). I had to separate the inputs to the two I/O blocks (pin (7) and pin (8)) in order for each not to trigger each other. Just curious if anyone has run into this issue.


  63. It’s just noisy. If you don’t have anything connected it can measure anything. If you want them to stay 0 put them to the ground. However mostly this is not necessary, just don’t do anything with those values of the pins you don’t use is enough.

  64. Thanks Kasper!

    And actually I (kind of) figured out a solution to my “pulseIn” question. Using the following, I can successfully detect input from any pin (push button or 300ms pulse) without running a refreshTimer:

    function onReceiveDigitalData(e:ArduinoEvent):void {

    trace(“Digital pin ” + + ” on port: ” + e.port +” = ” + e.value + ” pulse “+pulseCount+ ” bcount “+bounceCount);


    a.addEventListener(ArduinoEvent.DIGITAL_DATA, onReceiveDigitalData);

    I had to write a 50ms delay timer between pulses to get a more accurate result (100% success rate).

    Thanks again for this great package!

  65. Hi,
    I believe I have followed the instructions in the read me correctly.
    I am running arduino 1.0.5 for windows & have uploaded the standard firmatta & old standard firmatta, these both upload successfully but do not respond when pressing send in the serial monitor as it does in your video. I have a Leonardo R3 board.
    I have changed the serial port to 5 on both lines of the config file in the windows section & the terminal window opens with “waiting for clients” as the message.
    When I then run the monitor exe the terminal window declares “server thread launched” & “server(5) – thread started” the flash exe opens (flash player 10) with the message ” Connection with Serproxy established. Wait one moment” after this nothing happens.
    I am running windows 7 64bit SP1.
    Thanks for any help you can offer.

  66. I have just tried on a mac & it works fine, could still do with working out why it doesn’t work on the PC though. Thanks

  67. I can upload sketch’s to the Leonardo from the PC so I can only assume that part is ok. is there a way to see where communication is getting to in each direction? Thanks

  68. I got the monitor working. Very nice! i am trying to make a GUI with flash that sends instructions to stepper motors.

    Can you tell me how to set up AS3glue to see stepper motors attached to a Adafruit stepper motor shields (it has i2C)?

    The shield is mounted onto an Uno.

    I have a sketch that ican send to you that has the needed code that can control each motor.

    Thanks you.

  69. Hi Kasper,

    I am using Arduino LilyPad USB (Atmega32U4) and latest Firmata version on Windows7 and I did everything from the tutorial.

    However when I open monitor.exe it shows “Connection with Serproxy established. Wait one moment.” and nothing happens.

    Is there any solution for this?



  70. Maybe the firmata version is different. I didn’t test it with a lilypad and don’t have one to try things out. Just try different steps. You can also try a normal Arduino, if that works it’s probably at the side of the Lilypad.

  71. Hi Kasper, trying the standalone monitor and get the message ‘Failed to open comm port – connection refused’ in the terminal. Any suggestions to debug?

  72. Hi, Kasper.. how could we send a rgb value from as3 to arduino in order to iluminate a led rgb with the color provided? I’m using this but the led is not turned on:




  73. Hi,
    First thanks for this resource, its been a while since I played with an Arduino, and ran through your As3glue v14 and v 2 options with an Arduino Uno, both worked fine on OS X 10.6.8 as long as i substituted the cu.usbmodem option for the cu.usbserial option and edited the serproxy config file to match the 1.0.5 Arduino IDE. Is the reason for this because the Uno no longer uses an FTDI chip ? Note cu.usbserial was not an available option when Arduino 1.0.5 was installed. Are there benifits that I am not seeing to using the cu.usbserial option ( installing the extra drivers) when interacting between and Uno and Flash.( is it possible) Your advice appreciated.
    Regards Colm

  74. Is the reason for this because the Uno no longer uses an FTDI chip ?


    I don’t really get your other part of the question.

    This is how the config file should be.

    In Arduino the /dev/tty part is selected, but we will use the /dev/cu part below

    example Arduino Duemilanove and older:

    example Arduino UNO:

  75. Thanks for the reply and your answer, which has covered both questions, the 2nd question was worded after being reliable informed of one person interacting with an Uno via a cu.usbserial option which was not something I could replicate. I need to reintroduce myself to the Arduino :-) Thanks Colm

  76. Hi Kasper,

    How can I receive info on Pin 0 (RX) from a device (coin acceptor) that is connected via USB that creates a SERIAL connection?


  77. Hi Kasper,

    I am actually developing some kind of graphical user interface in flash like drag and drop flowchart. all I want is per symbol like servo motor if i drag it to the flow chart. It will produce a code and Can actually upload that code directly in arduino using flash..

    Is it possible?

  78. Hi, jim i got into the same problem but figured it out that windows firewall was blocking the port 5331, here is the link you can follow i know it’s toooooo late but may be it can help others :)

    I am using windows 10 and it’s working , what a great work kasperkamperman did in 2010 that i am still using it and it’s worth it.
    thank Kasperkamperman

  79. Hi how do you enable this using wifi. did you use serproxy. So correct me if i am wrong your arduino is still connected to the computer via USB. So the wifi on the computer lets you control it via mobile. Is there no direct communication via a andino shied and mobile. will it be possible via a Arduino Flash communication AS3 – Messenger library?

  80. If you would like to take the WiFi road, you probably have to find another source of information. You have to let Flash communicate over TCP/UDP (there is a bridge for that). I’d recommend looking to OSC communication. There are different libraries for that (Arduino/Processing) and maybe Flash.

  81. How about Bluetooth. There are several Bluetooth ANE available. Should I try that.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.