Arduino - code & tutorials
by beltran berrocal -
b@progetto25zero1.com

:: description ::
Here Are some code examples, tutorials and some utilities for Arduino. I decided to post them because I've learned a lot while developing them and I figured they could be usefull for everybody.

please tell me if you notice any bugs or have any comments on them

 

****************************************
     Quick Update - 2009-04
****************************************
The code that you are going to download was written initially for Arduino02, and then for Arduino04.
when I wrote the code the serial library wasn't available. if you compile them you'll get some warnings.

Luckily for you and me Michael Fairchild has updated the code to use the new Serial library (instead of the printByte method)
get the working code from gist.github.com/94327
and then follow the tutorial here after, the step by step instructions are still valid

:: serial Proxy on Mac ::
I've received many requests for help for this, so if you are having problems understanding/configuring the serial proxy on a mac, just download this zip with all the information:
- serial_proxy_on_Mac_explanation.zip


******************************************

:: serial communications :: (arduino04 code)
- serialCom_handeling_multiple_bytes_01
- serialCom_handeling_multiple_bytes_02
- serialCom_handeling_multiple_bytes_03
- serialCom_handeling_multiple_bytes_04 | has some reusable functions to read and Print long strings

******************************************

:: TUTORIAL + OLD CODE ::

:: Arduino.as Actionscript Class :: ( *updated for Arduino04)
a simple class that makes it easier to connect Flash and Arduino. very simple to instantiate and implement.
based on the original code of the flash client available on the Arduino website, by Yaniv Steiner and the Instant Soup crew.

The example shown is the most useless program ever ;-) ! it just creates a conversation between the Arduino board and a Flash Client.
It will teach you how to send, receive and handle long strings or other data to and from Flash using the Arduino class.
To make it work you will need the Serial Proxy, which is basically an XMLSocket server, a small program that runs
on your pc and keeps a live connection between the serial port and Flash.
The serial proxy is developed by Stefano Busti(1999) and David A. Mellis(2005) and can be found
either on the Arduino site or attached to this example

- download the example zip
- view the Arduino.as actionscript class

- view the Arduino code

Step by step instructions:
1- download all the zip file and decompress mantaining the directories

ARDUINO
2 - open the file _01_ArduinoConversation.pde in the Arduino IDE
3 - in the Arduino IDE check that right serial port is selected under the menu Tools >
serial ports
     annotate the numer of the port, you will need it for configuring the serial proxy (ex. COM6 num = 6)
4 - compile the software
5 - press and release the reset button on the board (the only button close to the icsp)
6 - right after rest DOUBLE CLICK the export button in the IDE
doubleclicking is a workaround for a small bug of version 00002 of the Arduino IDE. read here for more info. If you have a newer version of the software you won't need it.
7 - wait untill you see the confirmation that the file has been uploaded

SERIAL PROXY
8 - launch the serial proxy that can be found inside the folder _02_serialproxy
note: every time you want to upload a piece of software to the board, you will have to close the serial proxy because it interferes with the serial port: only one program at a time can communicate with the serial port.

FLASH
9 - open the flash file _03_FlashConversation + Arduino.as Class/FlashConversation.fla
10 - go to the layer A&L Arduino Connection and open the actions panel
11 - go line 64 were the Arduino class gets instantiated and change the port number to watever port number you noted down on step 3. NOTE: the Serial proxy uses reserved ports so you have to do a little trick to write the rigth port number: if your Arduino board is on COM3 port the number you will have to pass to the constructor is 5333, if your Arduino port was COM4 you will have to type 5334 ecc.
read or edit the serproxy.cfg file to better understand what this is all about.
       
var a:Arduino = new Arduino(5336); ( my Arduino is on port COM6 hence I put 5336 )
12 - hit Ctrl+Enter to test the movie and watch flash and Arduino talk to each other.


if you have any problems check these steps again, you might have done somenthing wrong...
if you still can't understand something write me a note or ask on the Arduino Forum

please tell me if you find any bugs or if you implement/upgrade the Arduino Class.