Thanks so much for you advice, it seems to be helping but not fully, just delaying the issue by a bit sometimes, as I’ll explain more below:
Just added a delay function to the code in arduino so it is now sending every second, inputs just have buttons connected to them, and the serial monitor looks like this(with and without timestamps, the red is sent when the button is pressed/ held down):
23:31:15.255 -> Red
23:31:18.269 -> Red
23:31:19.260 -> Red
23:31:20.254 -> Red
23:31:21.242 -> Red
23:31:25.246 -> Red
23:31:26.237 -> Red
23:31:27.233 -> Red
Red
Red
Red
Red
Red
I tried the trim function like this in processing and it appears to somewhat work, on my I can get one good read before the null pointer exception sometimes, other times it goes straight to the error:
[0] “COM3”
yes
NullPointerException
I’m a bit confused about option A for processing since I’ve never used a serial event before but maybe that is the answer, below is the processing code using a trim
import processing.serial.*;
Serial myPort; // The serial port
void setup() {
// List all the available serial ports:
printArray(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[0], 9600);
}
void draw() {
String Red = "Red";
while (myPort.available() > 0) {
String inBuffer = myPort.readStringUntil('\n');
String input = trim(inBuffer);
if (input.equals("Red")) {
println("yes");
}
}
}