You can communicate from Flash to an Arduino device by using a proxy. The proxy runs on a machine which is connected directly to the Arduino with a serial connection. Your AS3 code talks to the proxy over a TCP socket, and the proxy talks to the Arduino over the serial connection.

This whole setup is made pretty simple by Erik Sjodin’s as3Glue library:

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.

The library includes Arduino sketches and ActionScript 3 code examples as well as custom version of the Standard Firmata Arduino firmware and a serial proxy.

The AS3 portion of the library is released under the MIT license, and provides methods for setting pin modes and writing digital and analog data to pin output. It also provides event callbacks for receiving digital and analog data back from the device. The only wonky thing is that the proxy doesn’t appear to be released in source form (as far as I can tell), and it’s only provided as binaries for Windows and Mac users. On the bright side, it’s pretty easy to digest what’s happening from the file and the Standard Firmata protocol, so it wouldn’t be a huge ordeal to cobble together your own proxy if you know a little C or PERL.

as3Glue – Arduino control from Flash, Flex and AIR – a decent AS3 Arduino example
Firmata – host machine to microcontroller communication protocol

0 thoughts on “Arduino control with Flash AS3

  1. I used to work for a web shop that did balancing with an F5 BIGIP. The caveat “wait until nobody is left using the maintenance-mode machine before taking it offline” is actually kind of a problem in that you really can’t tell when all your users have dumped their session cookies. In reality you’re probably going to dump somebody’s session.

    A complete solution would be to use something like memcached so that any server could read data that was once stored on a different server.