Hi, I'm new with Processing and I have a problem when I try to split the data that I receive from the Serial Port from Arduino. I want to upload the data received into a database but the code doesn´t upload the data properly. I have printed the values of "serial" and "date" separately and I have realised that I am receiving all the data in the variable "serial" but nothing in the variable "date". So how can i fix this??
Here is the part of the code:
void draw()
{
if (myPort.available() > 0 && contador == 0){
myPort.write("T2222222222");
contador++;
}
val = myPort.readStringUntil('\n'); // read it and store it in val
if (val != null){
String[] a = split(val, '\n');
serial = a[0];
date = a[1];
db.connect();
db.execute("INSERT INTO example (data, hora) VALUES ('%s', '%s')", serial, date);
}
}