Serial port issues
in
Integration and Hardware
•
1 year ago
Hi
I wrote a bit of code to communicate with an arduino through serial communication, and everything works well (I can receive everything without problems etc), but now I want to be able to 'redefine' the serial port while the sketch is running.
I use controlP5 as GUI, and when someone selects an item from a dropdownlist (baudrate or port) then the serial port should be redefined with the current (wanted) settings.
this is what I use (this is not all the code, just the important things)
- import processing.serial.*;
- Serial port;
- int serialBaud = 19200;
- String serialPort = "COM3";
- void setup() {
- size(500,500);
- port = new Serial(this, serialPort, serialBaud);
- }
- void DDLitemselected(int newBaud, String newPort) {
- serialBaud = newBaud;
- serialPort = newPort;
- port = Serial(this, serialPort, serialBaud);
- }
any help would be greatly appreciated, thanks
Nick
1