Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

how to save serial data received from arduino

$
0
0
hello everyone, i apologize for my bad english yet, hope you can understand what my problem is:
i'm using arduino to take voltage values, then i send them to the serial port in this form:
  1. Serial.println(float,float,float,int,int);
data i send are stored in some array in arduino memory thus this instruction is a part of loop, so i send to the serial port multiple lines of the same type as this:
...
float,float,float,int,int
float,float,float,int,int
float,float,float,int,int
float,float,float,int,int
... and so on

i'd like processing to take these data from the serial port and then save them in some arrays in order analyze and plot.
so i wrote this code for processing:
  1. void serialEvent(Serial port) {
  2.   measure = commPort.readStringUntil('\n');

  3.   int i = 0;
  4.   if (measure != null) {

  5.     String[] valori_misura = new String[5];
  6.     valori_misura = split(measure, ",");

  7.     ps_voltage = parseFloat(valori_misura[0].trim());
  8.     PS_VOLTAGE[i]=ps_voltage;

  9.     c_voltage = parseFloat(valori_misura[1].trim());
  10.     C_VOLTAGE[i] = c_voltage;

  11.     current = parseFloat(valori_misura[2].trim());
  12.     CURRENT[i] = current;

  13.     ps_time = parseInt(valori_misura[3].trim());
  14.     PS_TIME[i] = ps_time;

  15.     c_time = parseInt(valori_misura[4].trim());
  16.     C_TIME[i]=c_time;
  17.      /*println(ps_voltage);
  18.      println(c_voltage);
  19.      println(current);
  20.      println(ps_time);
  21.      println(c_time+"\n");*/
  22.     i++;
  23.   }}
  hoping you've understood the code and what i want to do, i've a problem becouse i'm not able to print values of one of the arrays(eg.PS_VOLTAGE) ;

it's wrong how i save data? where do i have to put the for loop to print data? 

Viewing all articles
Browse latest Browse all 1768

Trending Articles