Hi there, im pretty new to the processing application, so bear with my knowledge.
Ive got a mpu6050 reading out yaw ptich roll angles on the serial monitor on aurdino IDE, but i want to save the output to a .csv file. im using “,” to split the values. im also using table() to create a table and add the values split by “’,” to its own colum. The file is not being created?
code below:
import processing.serial.*;
Table table;
String val;
Serial myPort;
void setup()
{
String portName = "COM3";
myPort = new Serial(this, portName, 115200);
table = new Table();
table.addColumn("id");
table.addColumn("sensor1");
table.addColumn("sensor2");
table.addColumn("sensor3");
}
void serialEvent(Serial myPort){
val = myPort.readStringUntil('\n');
val = trim(val);
println(val);
float sensorVals[] = float(split(val, ','));
TableRow newRow = table.addRow();
newRow.setInt("id", table.lastRowIndex());
newRow.setFloat("sensor1", sensorVals[0]);
newRow.setFloat("sensor2", sensorVals[1]);
newRow.setFloat("sensor3", sensorVals[2]);
saveTable(table, "data/new.csv");
}
void draw()
{
//visualize your sensor data in real time here! In the future we hope to add some cool and useful graphic displays that can be tuned to different ranges of values.
}
arduino serial output: