how to save serial data received from arduino
in
Core Library Questions
•
10 months ago
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:
- Serial.println(float,float,float,int,int);
...
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:
- void serialEvent(Serial port) {
- measure = commPort.readStringUntil('\n');
- int i = 0;
- if (measure != null) {
- String[] valori_misura = new String[5];
- valori_misura = split(measure, ",");
- ps_voltage = parseFloat(valori_misura[0].trim());
- PS_VOLTAGE[i]=ps_voltage;
- c_voltage = parseFloat(valori_misura[1].trim());
- C_VOLTAGE[i] = c_voltage;
- current = parseFloat(valori_misura[2].trim());
- CURRENT[i] = current;
- ps_time = parseInt(valori_misura[3].trim());
- PS_TIME[i] = ps_time;
- c_time = parseInt(valori_misura[4].trim());
- C_TIME[i]=c_time;
- /*println(ps_voltage);
- println(c_voltage);
- println(current);
- println(ps_time);
- println(c_time+"\n");*/
- i++;
- }}
it's wrong how i save data? where do i have to put the for loop to print data?
1