Serial connection from Arduino to Processing using Mac OS

First of all a Serial-USB-Driver needs to be installed. The driver of choice is called FTDIUSBSerial-Driver and as of version 2.2.16 for Mac OS can be used on Lion, even if it says otherwise. Restarting the computer after the installation is recommended.

Now create a new serial connection in Processing:

import processing.serial.*;
Serial port;
port = new Serial(this, Serial.list()[0], 57600);

Serial.list() gives you an array of all available serial ports on your Mac. In most cases index 0 is your choice. However you can specify the serial port with it's actual name, e.g. /dev/tty.usbserial-A6008e1I. A list of all USB-serial-devices on your Mac can be retrieved by entering following line in your Terminal.

ls -l /dev/*.usbserial-*

Compiling your Processing program you'll probably get an error called RXTX Version mismatch. To fix this, you'll need to replace two files in the Processing.app-Bundle. Download the RXTX from the RXTX-Wiki.

Show the package contents of the Processing.app. The files that need to be replaced with the ones from the RXTX library download can be found here:

Processing.app/Contents/Resources/Java/modes/java/libraries/serial/library/RXTXcomm.jar

Processing.app/Contents/Resources/Java/modes/java/libraries/serial/library/macosx/librxtxSerial.jnilib

Compiling you Processing-code once again, now you shouldn't get the RXTX version mismatch anymore. Perhaps you will get an exception called gnu.io.PortInUseException. Fixing this is easy: just run these commands in your Terminal:

sudo mkdir /var/lock
sudo chmod 777 /var/lock

Now the serial connection from Processing to the Arduino should work fine.