Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Arduino and Flash

Overview

There are 4 main components needed to getting an Arduino to communicate with Flash:

  1. Code to run on the Arduino: This sends data over the USB virtual serial port.
  2. A Serial to Socket Server: This takes data from the serial port and sends it over a network socket. Designed to be used with any client software (Flash etc) and any microcontroller.
  3. A Flash Socket Library: Actionscript code in flash that accepts and interprets the data coming in from the network socket. You can do this yourself, but why? - most people use an existing codebase.
  4. Your Flash Code (and Sample code): You custom actionscript code that does something interesting with the data. Some resources have sample actionscript code so you can learn by example.

NOTE: All of this can also work in reverse - Flash can send data to Arduino.

Resources

These are below, under the four headings described above:

Code to run on the Arduino

You can either

  • Make your own, using commands from the 'Serial Communication' section of Arduino Reference (Serial.print and Serial.read etc).
  • Or use an existing code sample. Some of the resources here have code samples.

There are two Arduino codesets that will be listed here because they are more than just samples - they are designed to be all that you would ever need to upload to the Arduino, after which time, you can just send serial commands to the Arduino to change what it is doing for you.

  • Firmata. Worth serious consideration for most projects. Never upload code to Arduino again - just get your software to send commands that will get Arduino to do what you need. It is being developed as a pseudo-standard, so has support for many software libraries, including Flash 9 (ActionScript 3) - see 'Glue' later.
  • Arduino > Flash code from Stephen Wilson at SFSU. This is like a simple version of Firmata (above). Also here is a Code library for Director, but does not seem to have anything for Flash.

Serial to Socket Server

The list of Serial-to-Network Proxy Servers and details can be found here. Some of the resources here include or have been tested with certain servers. Common ones are:

  • serproxy. In my opinion, the best option. Simple, fast, robust. Not as simple as TinkerProxy though, so some beginners might want to start with... (note, does not work on Mac OS X 10.6)
  • TinkerProxy. Based on serproxy, but has been updated to work on Mac 10.6. Allows both sending and receiving of Serial data.
  • SS6 Serial Server. Uses Java, which makes it platform independent, but unfortunately, Java does not support serial port communications without manually installing plugins. This makes it the hardest to set up, and quite slow. However, quite a few people have used this option.
  • Arduino2Flash. The author says "Some people using Intel Macs and OS X were unable to get serproxy configured correctly to connect Flash and the Arduino board. To work around this problem, I have written a replacement for serproxy in java called Arduino2Flash. This is experimental code, hacked together quickly, and probably buggy. Please test, let me know if it works, and I'll upload improved versions over time."
  • NETLab Toolkit Hub This is a robust server that supports communication with Arduino (via Firmata), OSC, XBee, and other protocols. It can be used with your own code that connects to it via sockets (it accepts multiple, simultaneous connections that access the same serial connection), or use it with the NETLab Toolkit Flash drag-and-drop widgets (see below). Mac and PC.

Flash Socket Library

  • Flash CS3 Binary Socket Example - Flash CS3 and Arduino sketch demonstrating connecting Flash to Arduino using the binary socket and TinkerProxy, from Brett Forsyth. While it has not been designed as a library, its code is short and can be easily used as a starting point.

  • Arduino Flash AS3 communication with Messenger library by Kasper Kamperman - Example based on the SerialPort class from tinker.it. It works together with the basic_communication example from the Messenger library.

  • Glue - Flex/ActionScript 3 class and sample code for Arduinos with Firmata

  • Arduino > Flash tools from Beltran Berrocal. Uses serproxy. Includes:
    • The 'Arduino.as Actionscript Class v1.0 (30-12-2005)', which uses Actionscript 2.
    • A sample flash app using 'Arduino.as Actionscript Class v1.0'.
    • Info on flash communication handling multiple bytes.

  • 'Flash Arduino IO' - Arduino <> Flash Communication from Kasper Kamperman. Based on 'Arduino.as Actionscript Class v1.0' (AS2) and uses serproxy. A clear and effective implementation. A complete video tutorial (that explains the revised version) can be found at Vimeo.
    • Monitor and set inputs/outputs on Arduino with Flash.
    • Sources, documentation and Serialproxy included.
    • Download revised version (10-2008) zip : Flash Arduino IO 2
    • Download old version zip : Flash Arduino IO

This is a bit of an exception to the rule - it uses the 'Arduino.as Actionscript Class v1.0' library, but its implementation is so effective and thorough, it can also be used as a library to base a project on.

  • SS6 Serial Server by Dan O'Sullivan. Is the official site of the SS6 Serial Server. It provides a pretty simple 'SS6 Flash Library' (AS1) (under flash tips) that has become quite commonly used. It also provides flash sample code and Arduino sample code.

  • MIDAS Serial Component by Tek-Jin Nam & Ji-Dong Yim at Co.design:Inter.action Lab. in the department of Industrial Design, KAIST. It provides flash components (works with AS2.0 and AS3.0 in windows and Mac) to make connection between flash and arduino by serial ports. It also provides installation software and flash sample codes.

  • NETLab Toolkit Widgets A collection of Flash components (AS3) that work with Arduino and other systems via the NETLab Toolkit Hub. The widgets can be configured and used with no coding - just drag and drop, but also have a code interface for more sophisticated applications. Widgets work in a dataflow configuration so that the output of one can feed the input of another. Widgets include AnalogIn/Out, DigitalIn/Out, AudioControl, VideoControl, ClipControl, MIDIOut, DMXOut etc.

Your Flash Code (and Sample code)

  • Arduino Flash communication AS3 by Kasper Kamperman Video tutorial on how to setup Arduino with Firmata, Glue (Flash AS 3.0) and Serialproxy (03-2010). Zip-package including Glue, Serproxy, documentation and example files.

  • Intro and samples for simple Flash <> Arduino from Jonah Model. Based on the work of Beltran Berrocal. So uses ''Arduino.as Actionscript Class v1.0' (AS2) and serproxy.

  • 'Arduino Vs Flash' Communication from Jowan Sebastian. Uses SS6 Serial Server and 'SS6 Flash Library'. Simple, customisable communication: DIY code + pics + downloads. Example uses:
    • 1 sensor into Flash to control a movie clip frame number.
    • Simple code that can be adapted to add more sensors.
    • USB / Serial Comm port and data gets pushed to Flash using Serial to Socket server.

  • Sending Multibyte Numbers from ActionScript to Arduino : Shows how to send multibyte numbers (Number / int (short)) from Flash to Arduino.
  • Flash and Arduino Communication : Shows two way communication between Flash and Arduino using XMLSocket.
  • Flash / Arduino Tips, Trick and Gotchas : List of tips and tricks when developing with Flash and Arduino.

Tutorials

  • Adobe Tutorials For Connecting Flash and Arduino : Adobe Software Evangelist Kevin Hoyt explains in a series of video tutorials the hardware and software stacks needed to connect Arduino with Adobe Flash using SerProxy. His approach takes advantage of the powerful sockets features of Flash and a Serial-To-Sockets Module called SerProxy.

  • Interfacing Flash and Arduino, from scratch : A complete tutorial from Jean-Philippe Côté on how to setup a working Flash/Arduino environment using the Arduino IDE, the FTDI driver, the Firmata sketch, as3glue and SerialProxy/TinkerProxy 2.

  • Getting Started with Flash and Arduino : An introductory tutorial written by Mike Chambers that shows how to set up Arduino, TinkerProxy and Flash to communicate with each other. The example code shows how to send and receive information between Flash and Arduino.

  • Getting started with the NETLab Toolkit A video and text that introduces using the NETLab Toolkit to connect Flash to Arduino - no code required.