This seems to be possible with as3Glue as per the: as3Glue is an ActionScript 3 library that enables communication between Flash/Flex/AIR applications and Arduino boards. It can together with one or several Arduino boards be used to monitor sensors (such as rotary encoders and motion detectors), control actuators (such as LEDs and motors) and interface other electronics (such as RFID readers) from Flash, Flex and AIR applications. As3Glue can be used with as3-arduino-connector as mentioned in the: Using with as3Glue Download either the SWC or Source Code from the Downloads section of this project for a patched version of as3Glue. This patched version has the exact same interfaces as v20, with a notable exception of the constructor. When you instantiate a new 'Arduino' object, replace the IP address and port with the COM port and baud rate. For example: public var myArduino:Arduino = new Arduino('COM10', 57600).
Now let's go to where you extracted the files from the zip archive. Let's open serproxy.cfg (in a text editor of your choice) and configure according to the following instructions. Below Is my configuration for Windows Vista with the Arduino on COM3.
I recently took the time to play around with node.js and it’s communication features especially serving as a communication port between arduino and a client eg. Flash or HTML. So far I used to connect Arduino to Flash.
I had it running some years ago and now it turned out to be quite a hassle. So I decided to give node.js a try. So the first step was to get Arduino and Node.js talking to each other 1. Arduino to Node.js This is the Arduino setup I used. A simple button and the build in LED.
Check out the detailed description here: (this is where the image is coming from) The script I’m using sends out a “1” if the button was pressed. This “1” is wrapped into a start and an end byte so that node knows where it’s coming from. For the incoming data I’m waiting for a serialEvent. It took me quite some time to understand how incoming serial data is handled. It’s different than I expected it to be.
Serial.available returns the number of bytes which came in. Let’s say there are 3 bytes waiting: a, b, c.
Serial.available returns 3. Serial.read now returns the first byte: “a”. The funny thing is that when you call Serial.available the next time it returns only 2. Every Serial.read call “eats” the byte it returns until nothing is left. You could do something like this. Init ( ); When running this code the following should happen – first upload the sketch to the Arduino and then start the Node application: 1.
In the terminal you will see the statement “open serial communication” 2. Node will send “$8” to Arduino. This switches on the build in LED of the Arduino. Pushing the button will print out a “1” in the terminal window Make sure you stay with those 2 sec delay. My Arduino resets on establishing a serial port communication.
It takes about 1.5 sec to get back to the normal state. If you send it earlier than 1.5 sec after the reset, this will get messed up. One trap I ran into was that I had the serial monitor of the Arduino open. This screwed things up.
As far as I understood a serial communication only works correctly between 2 partners. The serial monitor as a 3rd partner which makes things awkward. Make sure to keep it closed. What’s really annoying is that there is no nice way of debugging then I couldn’t find a solution for this so far.
Ok, now that we got the basic communication between Arduino and Node running up to the next level: 2. Arduino to Node to Air and back The Arduino sketch stays the same. This is the Node code.
The micro-controller is a powerful little wonder. We already know it can be programmed using the Arduino IDE, but wouldn’t it be cool if we could interact with it strictly using Flash? This article shows you how it can be done.
Once everything is set up, what can be achieved by the Flash/Arduino combo is pretty amazing. For instance, you can configure the board, read sensor inputs or trigger external equipments directly from the comfort of your beloved ActionScript 3 code. While this is all fine and dandy, getting there is a little more complicated than the ol’ plug-and-play.
Hang on, it might be a bumpy ride. If you are a Mac OS X user, Kristofer Joseph posted a similar tutorial targeted at Mac OS X.6 on his site. Check out hist post called. Update: while the procedure described on this page work fine, a new option is now available for Adobe AIR users. It involves the use of an ANE (Air Native Extension) that talks directly to the serial port freeing you from using a serial-to-tcp bridge. Free typestyler for windows. You can learn more about it on the. The Arduino Board Since you are reading this article, I am assuming you already own an Arduino board.
If not, you can buy one online at many electronics and hobbies shops. I bought my Arduino Diecimila (below). I am told is also a good spot for Arduino-related paraphernalia. The Arduino IDE Software First of all, if you haven’t already done so, get the.
The Arduino IDE is a Java application that allows you to write and upload code to the board through its USB (or serial) interface. By the way, the procedures outlined in this article have been tested to work on Windows XP – on a MacBook Pro;-). If you are using Mac OS X, Linux or some other version of Windows, your mileage may vary. Once downloaded, unzip the file and put the resulting folder in a convenient location. In theory, you should then be able to double-click the arduino.exe file to launch the IDE. However, this does not always work for me.
If you are experiencing a similar problem, you can launch the IDE by double-clicking the run.bat file. My understanding is that, in some circumstances, the Java environment is not properly registered with the app, thus the need to use the run.bat file to set the path and other system variables. The FTDI USB-to-Serial Drivers The Arduino IDE expects a serial connection to the Arduino. Therefore if, like me, you are using the USB-enabled version, you have to install the.
The driver is included in the Arduino package in the drivers FTDI USB Drivers folder. Upon plugging-in your Arduino, Windows will prompt you with the New Hardware Found wizard. Simply, direct the wizard to that folder and the installation will take place. To make sure everything is set up properly, in the Arduino IDE, open the “Blink” sketch from the File menu: A sketch is simply code that you want the Arduino to run. With the “Blink” sketch open, go to the File menu and select “Upload to I/O Board”.
This will upload the “Blink” code to the unit. After a few moments, you should see a LED blinking on the Arduino ( Yeah!). If this does not work for you, make sure you have selected the right board and port from the “Tools” menu.
If it still does not work, you should confirm that your board is indeed detected by your system. In Windows XP, you can do so by going to the “Device Manager” and checking that you do have a COM port labeled “USB Serial Port (COM?)”: On Mac OS X, you will most likely see two types of devices in the Serial port menu. There will be a terminal device (tty) and a call unix device (cu). To upload your sketch you can use either. However, in the SerialProxy configuration (see later) you need to use the cu device.
For example, on my Mac I get both /dev/cu.usbserial-A60049RW and /dev/tty.usbserial-A60049RW for my Arduino Diecimila. Once your setup is known to work, you can try playing with other sketches or even write your own. Check out the Arduino if you wish to do so.
However, in our case, we will only be using one sketch: Firmata. The Firmata Sketch Most of you now want to know how to make this thing talk to Flash.
The key is the Firmata sketch (which is bundled with the Arduino IDE since version 0012). As stated on: Firmata is a generic protocol for communicating with microcontrollers from software on a host computer. So, just as we did with the Blinksketch, load the Firmata sketch in the Arduino IDE and upload it to the board: Basically, once Firmata is on the board, we will be able to configure and program it directly from Flash using a host code library. If you want to confirm it has been properly loaded on the board, open Arduino’s Serial Monitor. Upon opening, it should print the following to screen “ StandardFirmata“.
The as3glue ActionScript Library We now have Firmata installed on the board but we need a matching software library that understands the Firmata protocol. For ActionScript 3, this library is called as3glue. You can from Google Code where the project is hosted. The SerialProxy Software Bridge We’re almost there But as it is now, there is no way for Flash to talk directly to the USB/serial port. In order to bridge this gap, we need to install the SerialProxy application. What it does is forward serial input and output to and from a network socket connection that Flash can use.
Last time I checked, serproxy.exe 0.1.4 was bundled with as3glue (in the applicationsfolder). This is the one you want to use. Do not use serproxy.exe 0.1.3 or older unless you are looking for trouble.
If in doubt, you can from my site. Before running it, you need to modify the serproxy.cfg file to match your system. Most likely, the only change you will have to make is assign the right COM port and matching TCP/IP port. For example, in my case, my Arduino is on COM port 7 and serproxy is listening for connections on TCP/IP port 5331: commports=1,2,3,4,5,6, 7,8,9 netport7=5331 commbaud=57600 commdatabits=8 commstopbits=1 commparity=none newlinestonils=false timeout=300 Make sure to end the netportparameter with the matching COM port number. As you may have guessed, this means that you can have SerialProxy talk to multiple Arduinos all at the same time and, if you so desire, accross a network.
Depending on your Firmata version, the baud rate could be 115200 or 57600. You can confirm that by looking at the standardfirmata.pde code in the Arduino IDE. Simply look for a setup routine near the end of the code. Inside it, you should find the following line which will tell you the speed to use: Firmata.begin(57600); If your Arduino gets assigned a COM port higher than 9 (I had this problem in one of my classes), serproxy.exe version 0.1.3 will not be able to access it. As stated above, always use.
You can then launch the serproxy.exe application. If everything went well, you should see a command prompt window with something like: Serproxy - (C)1999 Stefano Busti, (2005) David A. Mellis - Waiting for clients If you use TinkerProxy the output is different but you get the idea. This serproxy.exe process needs to be running all the time. At least, as long as you want Flash to communicate with your Arduino. Putting it all together Let’s now check if Flash can indeed talk to the Arduino.
In order to do this, you will have to put the as3glue ActionScript library in your classpath. The easiest way to do this is to grab the net folder inside the as3glue/as3/ folder that contains the library and put it right beside the.fla file in which you plan to use it. Then from the as3glue/examples/arduino/blink folder, open the blink.flafile in Flash. Look at the code in the first frame and make sure the port number (typically 5331) matches the one in the serproxy.cfg file then compile the Flash file.
You should see the following in the Flash file: Waiting for Firmata firmware version (reset your board). Just reset your board by pressing the reset button and you should see one of the LEDs start to flash.
Congratulations you have made it! Obvisouly, this is only the beginning. When you are ready to do more, start by looking at the as3glue page. When you’ve done that, you can find the full as3glue ( link down) on Bret Forsyth’s website. Troubleshooting If you do not see the blinking LED, the first thing to check is if serproxy.exe was able to open the configured COM port. To do so, right after compiling the Flash movie, switch to the serproxy.exe window.
If you see 'Failed to open comm port. Connection refused.' Double-check your serproxy.cfg settings because they are probably pointing to a wrong COM port. What you should be seeing after compiling the.fla, if everything worked right, is: 'Server thread launched'.
A very good troubleshooting tool called has been released by Kasper Kamperman and can be dowloaded on his site (I believe it is not part of the as3glue download package). This tool allows you to monitor Arduino’s inputs and outputs in realtime. If you cannot get your setup to work, try with his.fla file to identify if the problem is with your environment or with your ActionScript code. You will need to press your board’s reset button after compiling the.fla. Here is a list of additional common pitfalls you should watch out for while trying to interface Flash and Arduino:.
When you transfer the StandardFirmata sketch, make sure you have the right board selected in Arduino’s Tools-Board menu. For instance, I had a student who mistakenly identified his board as an Arduino Pro w/ ATmega328 while in reality he had a Duemilanove w/ ATmega328. The transfer completed just fine with Arduino giving no hints that something was wrong. The result was that some functions were working fine (like writing to a digital pin) while others did not work a all (like reading from a digital pin or printing to serial). Make sure you have the right character encoding for your serproxy.cfg file.
Be safe and use a programmers editor like (and not Notepad) to edit this file or you may end up with serproxy.exe starting and accepting connections but not transmitting to Flash properly. I also have seen a case where the Flash file seem to have been corrupted. Starting a new one from scratch fixed the problem (I have only seen this once and I’m not 100% convinced that this actually was the problem and not a mere coincidence but I guess it’s worth a try). There are security policies that apply if you try to run a swf file directly (as oppposed to compiling it in the Flash IDE). In order for a standalone swf file to talk to SerialProxy you must authorize it by going to.
Flash As3 Serial Communication Between Two Swf Files
You can authorize a single file, a folder or a whole drive. Check out my other article titled for further information on this topic. Of course there are always the four Rs of desperation: Reset, Restart, Reboot and Reinstall I truly hope you will not end up there!
Hope this helps! This is honestly the best step by step tutorial on the web.been trying for month to but this together and its going really well with your tutorial. Ive gotten to step 5 and my serproxy.exe is reading, Serproxy – (C)1999 Stefano Busti, (2005) David A. Mellis – Waiting for clients, although when I get to step 6 “then compile the Flash file.
You should see the following: Waiting for Firmata firmware version (reset your board) Just reset your board by pressing the reset button and you should see one of the LEDs start to flash.”?? When I do this nothing happens the serproxy.exe.?? Its just keeps on saying “blink.fla: blink on-board LED connected to Arduino pin 13” on my flash movie.Do you know what Im doing wrong? Or can give advice? Thanks a million. Hello Jean-Philippe!
This is the first tutorial after a long search that I fully comprehended, excellent commenting! Thank you very much. Unfortunately I am still experiencing a small problem: I followed your instructions in every detail. When I open the blink.fla with Flash, I can compile it nicely.
So when I hit debug (Ctrl+Shift+Enter) a window pops up reading “blink.fla: blink on-board LED connected to Arduino pin 13″ and in line 2: Waiting for Firmata firmware version (reset your board)”, but thats where it stops – even after resetting the arduino several times, waiting for 1 or 2 minutes in between. The serproxy.exe says: “Serproxy blabla – Waiting for clients”, “Server thread launched”, “server(4) – thread started” and than after some while (I assume after 8.6 seconds as specified as time out period in my serproxy.cfg) it displays: server(4) – timed out”, “server (4) exiting”. I am on a Win XP PC, using Flash CS3 with AS3, downloaded the latest as3glue and used the serproxy and firmata version that comes bundled with it.
My Arduino is a duemilanove, hanging on COM4. When I hit debug in flash without previously starting serproxy.exe, I get an error saying Error#2031: Socketerror.
So I guessed the communication between Flash and Serproxy is good, but not the one between the serpoxy and Arduino. I checked that both baude rates are set to 115200, in the Firmata as well as in the serproxy.cfg. So what I tried next is to start serproxy and in windows/run (windows-key+r) I typed in: telnet localhost 5331.
The serproxy window again displays “Serproxy blabla – Waiting for clients”, “Server thread launched”, “server(4) – thread started” and when I now press reset on my arduino, in the telnet window two symbols (an “a” with an “°” on its top and the symbol spade from a cards game) appear. I looked the symbols up in an ascii table and they correspond to dec 134 (hex 86) and dec 6 (hex 6) – at least thats what I found. So, at least the arduino sends something – but it doesn’t get through to Flash or it has not the right format. Do you have any ideas, what my problem could be? I would totally appreciate your help since you seem to have quite some experience on this topic! Thank you very much, greets Sebastian ps: sorry for the long comment feel free to delete it and send me an email instead! It works now.
In case someone experiences the same problem, here is what helped me: In the StandardFirmata.pde, in the end of setup the function Firmata.begin is called. So I looked in the Firmata.h file and found, that the begin function is overloaded: there is one called begin and one begin(long), which means if you call Firmata.begin without an argument, then the Firmata::begin(void) inside the Firmata.cpp is called, which has starts the Serial communication with a default speed of 115200. However, if in the StandardFirmata.pde you call Firmata.begin(115200), the second version Firmata::begin(long) is called, which accepts a long variable for the Serial communication speed. When I replaced the code Firmata.begin in the.pde with the line Firmata.begin(115200) everything works perfectly now:o) Actually it should be the same, since the standard baude rate in Firmata.begin IS set to 115200, but for some reason this didn’t work for me. Hope I could help some of you out there, cheers Sebastian (its blinkiiiing, jeah!!! Hello JPCOTE, What a great tutorial – thanks for all your help so far!
I have got everything working with the Actionscript from the ‘as3glueprogram-example.fla’ file pasted into the first frame on my Flash timeline and am now beginning to attempt to write my own Flash programme Essentially, all I want it to be able to do is to play my animation in the main timeline and then to send ‘HIGH’ signals to different Arduino outputs when it gets to different frames on the timeline. I am trying to do this by pasting in the ‘a.writeDigitalPin(6,1);’ command into the Actionscript for that specific frame, But this does not work. Do you have any suggestions of how I can get this command to work across different frames in the main timeline? I tried to paste in all the Actionscript code from the first frame (which sets up the pins etc) into this other frame, but this did not work either. Any help would be much appreciated – I am a novice (both with Flash and Arduino, Sorry!) MAny thanks, Ellie. Hi Jean-Philippe I find it amazing your tutorials.very explicit!You know.I am a technician in electronics and I am doing my first baby-steps towards microcontrollers.For that reason I was recommanded Arduino Duelminove which I bought it but I did not have the chance to benifit from it.The reason is when I download the software(I am using windows sweet 6 and before I was using vista) from arduino page,I click to unzip the files but nothing happened.Would you please guide me,I am desperately in need of your help to work on projects. Thank you very much Adam.
Hi i have been trying to get this to work for the last 2 days and its really annoying me lol i have followed all the steps on this page but it just doesn’t work and i feel as if i have tried everything when i run the flash program it says – Error #2031: Socket Error. URL: 127.0.0.1 – Did you start the Serproxy program?
However the serproxy works perfectly fine so does the arduino board i can upload a sketch without any issues i feel as if i have tried everything, i have pinged 127.0.0.1 and it worked i have gotten into the windows host file and 127.0.0.1 has been set to my localhost. I have done the flash player trust thing, modified the security settings and also Compile as a projector. I have tried using telnet in the command prompt and it just wont communicate through port 23 and i know i tried a few more things but still not connecting so if u can help me and tell me how to solve it step by step i will be rally grateful thank you so much. The way to check if serproxy.exe is set up correctly is to start it in one window and to try to manually connect to it in another window. You can do that by using the telnet command.
Basically, this simulates what Flash does when it tries to connect to serproxy.exe. When you issue the telnet command in the second window, you must use the ip and port that serproxy is listening on. For example: serproxy 127.0.0.1 5331 If you get a prompt, serproxy works. If not, there is something wrong either with serproxy or with your network setup. Telnet is now disabled in newer Windows versions. Check out this article for details on how to activate it.