We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi guys, in my project i have to communicate with arduino by the serial port. I'm using this code:
port = new Serial(this, Serial.list()[0], 115200);
But is there a way to find automatically the right port? because on others computers i have always to change the number of port, like 1 or 2. Is there a command that can do that?
Thank you
Answers
https://forum.Processing.org/two/discussion/13492/storing-input-after-using-jpaneoption
int idx = int(loadStrings("port.txt")[0]);
is enough to grab the stored value.https://Processing.org/reference/loadStrings_.html
String port = Serial.list()[idx];
. And finally:new Serial(this, port, 115200);
.If you have multiple Arduinos you could store a number in the Arduino code and ask it to send the number to the Processing sketch. You'd have to create a new Serial object for each connected device but only use the one with the correct number.