Hello, I am a beginner with Arduino. I have attempted to do the Networked Lamp project specified in the Getting Started with Arduino book. The Arduino sketch compiled fine, but the processing code gives me a error (Error inside serial.ports) at the following line:
String arduinoPort = Serial.list()[0];
How do I fix this? The window does not show up at all. I am using a Raspberry Pi with modified 32-bit Processing 1.5.1. My code is exactly the same as it is in the book.
I am currently testing a wifi shield using udp and a RPi. Here is the link to the Arduino sketch and the Linux code http://forum.arduino.cc/index.php?topic=198259.0
The Linux code runs on a LAMP server and the Raspberry Pi.
Yes; my Arduino is on /dev/ttyACM0, which is normal for Linux; however, even serial.list will not run (same error).
And SurferTim, don't advertise your posts.
I wasn't "advertising" my post as much as saving myself a bunch of typing. Don't let my foolish attempt at providing assistance get in your way. March on, brave soldier!
My code is exactly the same as it is in the book.
Maybe you need a new book.
edit: It was the "networked lamp" part that confused me. Is your goal to communicate with the Arduino over the Linux serial port? I have functional C code that does that around here in one of my Linux boxes. Maybe some day I will look for it.
...sorry SurferTim, didn't understand...
Anyway, I am not using a shield or anything; just a standard UNO R3 (not SMD). The processing code is handling all of the networking bits, but I cannot connect to the Arduino using processing due to the code problems above. I'm starting to give up on this project...
The Serial.list() method returns a list of serial ports that the Arduino might be connected to. That list COULD be empty. You are accessing the first element in a possibly empty list. If the list is empty, you should not be accessing any element in the list.
If the list has one item in it, is it NOT safe to assume that the Arduino is actually connected to that port. You must print the list, and see if the Arduino port is actually in the list.
If the list has more than one item in it, it is NOT safe to assume that the Arduino is actually connected to the first item in the list. You must actually print the list, and determine the correct index.
You must actually tell us which of these three cases you are dealing with.
I am not sure about which case I am dealing with; when I try to access Serial.list by un commenting the line, it gives me the same error. If helpful, I had to replace some files in the Processing folder to make it work on RPi; including RXTXcomm.jar if that has anything to do with it. When I put the following command into the terminal:
ls /dev/tty*
it returns a lot of tty numbers, as well as /dev/ttyACM0 (Arduino UNO R3), /dev/ttyAMA0 (I think that's the built-in USB hub) and /dev/ttyprintk (?) all in the order aforementioned. I think that this is not a problem with the ports, I think that it's a problem with some of the files I replaced. Here's the tutorial for Processing on RPi: