I want to use the muscles of Processing to get my Arduino do really cool stuff. In order to do this I want both of the softwares to talk to each other. It proves to be a bumpy road depending on versions of you Arduino board and processing. My set up is a Mac OS X 10.6.7, Arduino board Duemilanove with Atmega328. If you already have the Arduino and Processing software installed do the following:

1. Download the Processing library, unzip it.
2. Put the folder “arduino” inside a folder that you call “libraries” within your Processing Sketchbook folder.
3. Connect your Arduino board and open up the Arduino software, upload the sketch StandardFirmata from Examples/Firmata. Close Arduino software.
4. Add a LED diod to pins Ground and 13 on the Arduino board and run the following code in Processing:

import processing.serial.*;
import cc.arduino.*;

Arduino arduino;
int ledPin = 13;

void setup()
{
//println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(ledPin, Arduino.OUTPUT);
}

void draw()
{
arduino.digitalWrite(ledPin, Arduino.HIGH);
delay(1000);
arduino.digitalWrite(ledPin, Arduino.LOW);
delay(1000);
}

Whoohooo!!!! You should now see your LED blinking on and off.

Troubleshooting

Mismatch of RXTX libraries
When running your Processing sketch the following error can occur:

WARNING:  RXTX Version mismatch
Jar version            = RXTX-2.2pre1
native lib Version  = RXTX-2.2pre2

1. Download the latest RXTX library from http://rxtx.qbang.org/

2. Find the files librxtxSerial.jnilib and RXTXcomm.jar in the unzipped folder structure: MACOSX_IDE/ForPackageMaker/Install/Java/Extensions

3. Copy the 2 files into the folder: Harddrive/Library/Java/Extensions

4. Close down Processing and right-click on the application in the “Applications”-folder and select “Show Package Contents”. Go to folder “Contents/Resources/Java/modes/java/libraries/serial/library”. Replace the old RXTXcomm.jar with the new file in this folder.

5. Replace the file librxtxSerial.jnilib with the new file in the “macosx” folder “Contents/Resources/Java/modes/java/libraries/serial/library/macosx”.

6. In order for this to work properly also follow these steps taken from here:

1. Under Finder click on the “Go” Menu
2. Select “Go to Folder…”
3. Type “/var/”
4. Finder will open var folder.
5. Right click on folder named “lock” and select “Get info”
6. Open drop arrow titled “Sharing & Permissions”
7. I set all privileges to: “Read & Write”
8. Close Info
9. Go to the Var folder on the finder and open the “spool” folder
10. Right click on folder named “uucp” and select “Get info”
11. Open drop arrow titled “Sharing & Permissions”
12. I set all privileges to: “Read & Write”
13. Close Info
14. DONE

7. Restart your computer and Processing. The output you should see is:

Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7

RXTX Warning
If you got this warning. Make sure you went trough the entire step 6 in the previous block and that the user you are logged in as have the permissions to read & write on these files.

RXTX Warning:  Removing stale lock file. /var/spool/lock/LK.255.000.134