We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi All,
Is there a way to have Processing search my arduino serial port (port 7 for me) until a connection is found? If there's no connection (my Arduino isn't plugged in), it gives me an error saying so and doesn't allow me to run the program. I want to be able to use the interface without the arduino present, and once I manually connect it, I want to have my code recognize it and begin to transmit and communicate with it. All help's appreciated, thanks a lot!
Pat
Answers
Good idea! If the Arduino is the only serial device that will be connected to the computer running Processing, should be easy to do. The only array element returned by Serial.list() will be the Arduino, so if there is a value on Serial.list()[0], it must be the Arduino. The problem becomes more difficult if you have multiple serial devices connected. You would need to loop through the Serial.list() array to find the com port that the Arduino is on, and that can change if your computer is dynamically assigning a port number every time you connect the Arduino. With Linux you could use udev rules to make the OS assign the same name to the Arduino's port regardless of which tty it is on. I expect you could do something similar in Windows or Mac, but I am not sure how off-hand.
I use a basic handshake so processing can tell when it's found the right port ...
http://forum.processing.org/two/discussion/5740/is-there-a-way-to-check-a-serial-port-until-a-connection-is-made#Item_2
Nice, robj66.