We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › how to read the serial Port
Page Index Toggle Pages: 1
how to read the serial Port (Read 292 times)
how to read the serial Port
Jul 8th, 2006, 7:18pm
 
Hello Everybody,

I'm very new to processing and have a simple question:
I bought an Arduino-Board and try to do some code on the computer, when it is plugged in. my Code looks like this:

Code:
import processing.serial.*;

Serial myPort;      

void draw(){
 // List the serial port 0:
 println(Serial.list()[0]);
 if(Serial.list()[0] == "/dev/tty.usbserial-0000101D"){
   println("Arduino-Board plugged!");
 }
}


the line »println(Serial.list()[0]);« works very well, but when I try to do the if-loop, nothing happens. (the name of the Port is right!)

What am I doing wrong?

Rasso
Re: how to read the serial Port
Reply #1 - Jul 9th, 2006, 2:21pm
 
== doesn't work too well with Strings, use:

Serial.list()[0].equals("/dev/tty.usbserial-0000101D");
Page Index Toggle Pages: 1