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 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:
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:
=========================================
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.








SlunD 12:41 on June 7, 2011 Permalink
Hi
Im a real noob at processing and Im getting the:
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
However Im working on windows and Ive been unable to find any help on how to install the RXTX library, any chance you know how to do this on windows aswell? Besides from that, its a wonderful article – really helped understanding what im actually doing atm
Ellen 08:35 on June 13, 2011 Permalink
Which Windows version are you on? Try these steps and see if it works:
Download Binary files for Windows here:
http://rxtx.qbang.org/wiki/index.php/Download
Copy the following files from the downloaded zip:
RXTXcomm -> C:\Program Files\processing\java\lib\ext
rxtxSerial.dll -> C:\Program Files\processing\java\bin
rxtxParallel.dll -> C:\Program Files\processing\java\bin
Restart Processing.
bruno 23:40 on June 14, 2011 Permalink
I can’t unzip the file..
I use Windows :S
bruno 23:42 on June 14, 2011 Permalink
can you sendme the file unzipped?
I’m from Argentina, I don’t speak very well
Ellen 14:49 on June 17, 2011 Permalink
Bruno, you can download the zip from here: http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip There is a folder for Windows files with all the files you need. Let me know how it goes.
kerry 20:34 on June 20, 2011 Permalink
I’ve also downloaded the file rxtx-2.1-7-bins-r2.zip and cannot unzip it. In Windows XP it causes an error saying the file is corrupt.
Ellen 09:29 on June 22, 2011 Permalink
Kerry and Bruno, I have zipped the Windows specific files for you to download here: http://www.sundh.com/files/rxtx_fix_windows.zip
Christian 07:01 on June 29, 2011 Permalink
I suppose you meant C:\Program Files\Java\lib\ext and not C:\Program Files\processing\java\lib\ext -because there is no “java” folder in the processing folder?
And to you noobies who can’t unzip; try winrar or anything else you can find at download.com…
Christian 08:12 on June 29, 2011 Permalink
It’s working now. I did just as I mentioned above (->C:\Program Files\Java\lib\ext).
Jose 22:44 on July 13, 2011 Permalink
Ellen, i tried doing everything you did but i ran into a problem. I don’t have a lock folder. I’m running 10.6.8.
It doesn’t say i have a mismatch. the only problem is a Serial.init() problem.
Ellen 07:33 on July 14, 2011 Permalink
Hi Jose!
What error do you get at Serial.init?
Jose 13:33 on July 17, 2011 Permalink
Sorry for the time it took me to reply. I figured it out. Don’t exactly know what i did different but it works now. Thank you!
Roger 00:31 on July 21, 2011 Permalink
Two remarks: 1. Processing works with Arduino without problems despite the RXTX warning. 2. The line “new Arduino(this, Arduino.list()[0], 57600);” however connects to the first free serial port in the list which may not be what you need. To find out which serial port talks to your Arduino, open the Arduino IDE and look up “Tools > Serial Port”. Compare that to the entry in in the
“println(Arduino.list());” and select this one.
Christian 13:22 on July 26, 2011 Permalink
Now how do I remove these RXTX libraries? Actually, I went from using Processing to using Matlab instead to communicate with the arduino. It works well with an another arduino but not with the one that got the new libraries installed?!
Antonio V. 09:57 on August 1, 2011 Permalink
hi can you please tell me the exact location of the libraries folder plz
salemlab 17:33 on August 10, 2011 Permalink
Hi Ellen, hi everybody,
Thanks Ellen,
your technic seems to work and the library becomes stable but I’ve
the same problem than Jose (i get an error at “Serial.init” ).
It drives me crazy. I found this topic on another forum, and the guy seem
to have solve it, but i don’t understand what he means in his sentence :
“Re: Error inside Serial.()? Serial Problem
Reply #5 – Apr 30th, 2010, 7:15am
“i had the same error message because i had put the constructor for the serial port (port=new Serial(… before the size(… entry in setup. apparently a no-no.”"
http://processing.org/discourse/yabb2/YaBB.pl?num=1229887443
Anyone have suggestions to solve this Serial init problem ?
I’m lost :/.. please.
ricard 08:46 on August 11, 2011 Permalink
Hi, i installed processing and this is my error, I fix the problem with rxtx libraries, but now i have this message:
(arduino works fine, with any error)
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.(Serial.java:139)
at processing.serial.Serial.(Serial.java:105)
at cc.arduino.Arduino.(Arduino.java:169)
at arduino_pwm.setup(arduino_pwm.java:31)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
Exception in thread “Animation Thread” java.lang.RuntimeException: Error inside Serial.()
at processing.serial.Serial.errorMessage(Serial.java:591)
at processing.serial.Serial.(Serial.java:151)
at processing.serial.Serial.(Serial.java:105)
at cc.arduino.Arduino.(Arduino.java:169)
at arduino_pwm.setup(arduino_pwm.java:31)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
Thanks, ricard!
ricard 15:48 on August 14, 2011 Permalink
I can solve my problem:
http://jlog.org/rxtx-mac.html
Gianmarco 22:35 on August 14, 2011 Permalink
Ellen, I have followed your instructions so far and they have been very helpful.
I have a new problem now.
If I try to export to application in “processing” it says “Could not copy source file:xxx”
Looking arount it looks like processing has some issues with some libraries, among which, also “processing.serial”.
Any idea how to solve this?
Matt Slusarz 00:58 on August 17, 2011 Permalink
Hi,
I just wanted to mention a fix I found. First off I wasn’t having any issues other than getting the error message. It just annoyed me so I had to fix it.
I got my solution from here
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1280537327
Re: Arduino SW crashes on MAC OSX Snow Leopard
Reply #2 – 06.01.2011 at 18:20:36 Thanks~ It was very helpful
But downloaded version dosen’t work for me
So I replaced RXTXcomm.jar and librxtxSerial.jnilib in /library/Java/Extentions directory with the one in Arduino-0022 pakage (/Application/Arduino.app/Contents/Resources/Java)
And it works well.
I get this output instead of the error now :
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
Larry 17:00 on August 18, 2011 Permalink
Hi,
I am running OS X Lion (10.7.1). I followed the steps exactly but…
1) I didn’t have a “lock” file.
2) The problem got worse. Here is the output:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.(Serial.java:139)
at processing.serial.Serial.(Serial.java:105)
at serial_test2.setup(serial_test2.java:26)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
Exception in thread “Animation Thread” java.lang.RuntimeException: Error inside Serial.()
at processing.serial.Serial.errorMessage(Serial.java:591)
at processing.serial.Serial.(Serial.java:151)
at processing.serial.Serial.(Serial.java:105)
at serial_test2.setup(serial_test2.java:26)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
Any advice?
Thanks
Andy 18:14 on August 28, 2011 Permalink
Same as Larry – now Arduino won’t upload. Saying that Processing is already using the usb serial port.
Here’s what i get output from the Arduino after a restart (and nothing else run – i.e. processing):
processing.app.SerialException: Serial port ‘/dev/cu.usbserial-A900aeQ7′ already in use. Try quiting any programs that may be using it.
at processing.app.Serial.(Serial.java:144)
at processing.app.Serial.(Serial.java:76)
at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:75)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:93)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:56)
Any help?
Andy 18:22 on August 28, 2011 Permalink
Fixed it!! If you’re still in having a problem Larry.
If you don’t have /var/lock/
then:
In a terminal window do the following where % is your prompt
%sudo mkdir /var/lock/
password:
Locate the file you’ve just created and set the permission as above.
Restart Arduino and it should work.
Not sure why OS X Lion doesn’t have this lock file…but ha-ho.
Cheers,
Andy
Larry 05:48 on August 31, 2011 Permalink
Andy,
Thank you it worked! You’ve made my day!
Cheers!
heneghat 18:55 on September 3, 2011 Permalink
Guys, i am running ubuntu 11.04. I have loaded Arduino through software centre and it works well with Arduino controller. have completed some of the tutorials. I have just downloaded processing 1.5.1 and keep getting the RXTX version mismatch. Jar version 2.2 pre1 and native lib version RXTX 2.2pre2 error. Processing is working as i can draw a circle,etc.. but thats it. Cannot communicate with Arduino. First error i got in processing after loading standardfirmata onto arduino board was “cant find cc library”.. Very frustrating. Any ideas?
Ahmad 19:26 on October 12, 2011 Permalink
I have the seam problem. I am using Windows XP. I downloaded “rxtx-2.1-7-bins-r2.zip” but, when I unziped this file, I have only one file (rxtx-2.1-7-bins-r2). When I unziped the file (http://www.sundh.com/files/rxtx_fix_windows.zip) that Ellen posted, I see rxtxParallel.dll and rxtxserial.dll, but I do not see RXTXcomm. Where can I get this file?
Thomas 21:27 on November 2, 2011 Permalink
Great tutorial!
I did step 6 exactly as mentioned above (I had to create the lock folder) and the sketch works fine, but I still get the following error message every time I start the sketch: RXTX Warning: Removing stale lock file. /var/lock/LK.008.011.000
Do you have any suggestions?
Thanks,
Thomas
salemlab 21:44 on November 4, 2011 Permalink
hi
have a look at the end of this topic to fix maybe the problem of the RXTX mismatch.
https://forum.processing.org/topic/rxtx-version-mismatch-on-a-macbook-pro-nothing-seems-to-solve-this-problem
CARMEN 17:25 on November 27, 2011 Permalink
HI everyone, i just had the same issue on the processing, i did exactly what elle says, but i don’t know if there’s an other library that i have to copy just becase i’m using WindowsXP, i did all the pasting the files and now the warning window shows me this:
java.lang.NoClassDefFoundError: javax/comm/CommDriver thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: javax/comm/CommDriver thrown while loading gnu.io.RXTXCommDriver
Exception in thread “Animation Thread” java.lang.ArrayIndexOutOfBoundsException: 0
at CUBO.setup(CUBO.java:46)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
And on my scketch board the line that says
myPort = new Serial(this, Serial.list()[0], BAUDRATE);
it’s on yellow, i would aprecciate the prompt response
Mark Amos 21:05 on January 1, 2012 Permalink
Ellen – thanks for the tutorial. I’ve been playing with the Arduino for a week or so and thought I’d take a look at “processing” – you’re demo was very helpful.
willy 13:15 on January 3, 2012 Permalink
thank you sooooooo much!
but i still have the problem Removing stale lock file. /var/spool/lock/LK.018.019.000 at the step 6…
how can i fix the problem?
Spandy 00:18 on February 2, 2012 Permalink
Hi guys
I am a newbie to arduino. I am using arduino uno (EtherTen) and SHT15 sensor. I have got the sensor to communicate with the serial port. I am working with Windows XP. I had rxtx problem and I solved that my updating the rxtxcomm.jar file and also the other two files in the java/bin folder. bt still i got the below errors
Next I wanted to send the temperature and humidity readings sensed by SHT15 into a email. I almost got that working too. but today I came and set everything up again and the Processing was not reading the port values. Processing is giving me these errors. I checked the serial port it is working fine and updating the sensed values(btw the values are “float”).
Please help.I have searched the below errors and could not find a solution which is applicable to my problem.Please help..I have been at it for a while can not solve it.
import processing.serial.*;
int val=0;
Serial myPort; // The serial port object
void setup() {
size(200,200);
println(Serial.list());
myPort = new Serial(this, Serial.list()[1], 38400);
}
void draw() {
// Set the background
background(val);
}
// Called whenever there is something available to read
void serialEvent(Serial port) {
val = port.read();
// For debugging
println( “Raw Input:” + val);
}
***************************************************************************************************************************************
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[0] “COM1″
[1] “COM4″
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.(Unknown Source)
at processing.serial.Serial.(Unknown Source)
at Email.setup(Email.java:62)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
Exception in thread “Animation Thread” java.lang.RuntimeException: Error inside Serial.()
at processing.serial.Serial.errorMessage(Unknown Source)
at processing.serial.Serial.(Unknown Source)
at processing.serial.Serial.(Unknown Source)
at Email.setup(Email.java:62)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
Ellen 22:35 on February 14, 2012 Permalink
Hi Spandy!
How come you use Processing for your EtherTen? You can run your code and upload it from Arduino IDE and not be dependent on Processing running on the computer since you have an EtherTen with ethernet connection.
Gerard 18:08 on February 17, 2012 Permalink
Hi.
Just came across your site and am I glad.
I am desperately trying to get arduino and processing to talk to each
other in Ubuntu 11.1. I think I have run into every possible problem.
I would love a complete run down of instructions if you are familiar with this process.
Desperately Seeking Info!!!
Stuart 06:11 on March 31, 2012 Permalink
Hello ,
Try as I might I constantly get the message “No library found for cc.arduino”.
I have arduino folder in the Sketchbook location directory indicated in the Processing preferences. In my case its C:\Processing\libraries.
This arduino folder contains “library.proreties” and three sub-folders called examples, library and src.
I’m sure I am doing something fundamentaly wrong but read read and read as I do I can’t discover what it is.
I have tried every combination of putting folders in directories I can think of .
Oh, it’s a Windows 7 computer if that makes a difference
Thank you.