Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to fix this? Split function

$
0
0

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);
         }
       }

Viewing all articles
Browse latest Browse all 2896

Trending Articles