It is very exciting for me to interface a circuit with a program.
Last night I made the following example which comes with the libraries I used.
So this is how you can do it:
1. Download the Processing IDE from processing.org (I suggest to use the stable version 1.5.1 )
2. Download the processing library for arduino: processing-arduino.zip
(properties file here: processing-arduino.txt)
3. Unzip the library and copy the “arduino” folder into the “libraries” sub-folder of your Processing Sketchbook. (You can find the location of your Sketchbook by opening the Processing Preferences. If you haven’t made a “libraries” sub-folder, create one.)
4.Run Arduino, open the Examples > Firmata > StandardFirmata sketch, and upload it to the Arduino board. Now you can close the Arduino IDE.
5. In Processing, open one of the examples that comes with with the Arduino library.
6.Edit the example code to select the correct serial port. So you have the following code in the beginning:
On the 12th line you have Serial.list() where you might change the  according to which port you are using with your arduino(I’m using ). Here is the list:
7.Run the example.
You might get following error:
The you should solve the problem following these steps:
2. Find the files librxtxSerial.jnilib and RXTXcomm.jar in the unzipped folder structure: MACOSX_IDE/ForPackageMaker/Install/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”.