Savid sensor data from arduino to processing in .csv file


hello,
i've got problems uploading serial data arduino processing , saving in .csv file
not right value goes right column cell

my arduino script goes follow:

//tmp36 pin variables
int sensorpin = 0; //the analog pin tmp36's vout (sense) pin connected to
                        //the resolution 10 mv / degree centigrade a
                        //500 mv offset allow negative temperatures
 
/*
 * setup() - function runs once when turn arduino on
 * initialize serial connection computer
 */
 
float val = 0;     
void setup()
{
  serial.begin(9600);   
}
 
void loop()                     // run on , on again
{

 val = analogread(sensorpin); 
 

  serial.println(val);// print out voltage
 
 
delay(20);                                     //waiting second

}


my processing script goes follow :

import processing.serial.*;
serial myserial;
printwriter output;
void setup() {
   myserial = new serial( this, serial.list()[3], 9600 );
   output = createwriter( "databestandje.csv" );
}
void draw() {
    if (myserial.available() > 0 ) {
         string value = myserial.readstring();
         if ( value != null ) {
              output.println( value );
         }
    }
}

void keypressed() {
    output.flush();  // writes remaining data file
    output.close();  // finishes file
    exit();  // stops program
}

the output of .csv file goes follow


can explain why  example @ row 11 , 12 gives 55  , 5.00 while should give 555.00

how structuring input using
code: [select]
int lf = 10;    // linefeed in ascii
...
myserial.readstringuntil(lf);
instead of grabbing whole buffer?

why run communication 9600 baud?


Arduino Forum > Using Arduino > Programming Questions > Savid sensor data from arduino to processing in .csv file


arduino

Comments