Hi
I have done a small program in Processing. The thing is that i want to be able to connect to the arduino when i want to, not by startup.
what I want is to move down the command arduino = new Arduino(this, Arduino.list()[7], 115200); to void draw
how do I do this ?
what I want is to move down the command arduino = new Arduino(this, Arduino.list()[7], 115200); to void draw how do I do this ?
The object, arduino, is declared as a global object. You can value it anywhere.
Valuing it in draw is NOT a good idea, because draw(), like loop() is called in an endless loop(). You do not want to create a new object on each pass through draw().
Is there something about that message that you don't understand?
When the "new Arduino" call was in setup(), this was one thing. When you move it into the button callback, this is something else (an instance of the Button class).
I thought it was something with the serial string. But it was the undefined link to the string inside the button.
Thanks anyway, took me only the hole night to figure this out =).
This with the serial is something totally new for me. it there a way to see if I have got a connection by the serial ?
like ?
if(connected to serial this, Arduino.list()[7], 115200){
do this;
}
it there a way to see if I have got a connection by the serial ?
If you try to connect to a serial port that is in use, there will be an exception thrown. You can use a try/catch block to catch the exception.
Of course, you should be smart enough not to try to run the Processing application while the IDE is uploading a sketch or the Serial Monitor is open.
Once the Processing application connects to its end of the serial port, there is no way to tell whether there is anything on the other end, unless that something replies to a message sent from the Processing application.