I’m writing a code that receives the value of a potentiometer at all times (float val_pot2)
I created a function to record these values in a table in .csv format
I have the following problem: I am not able to save a new value in each line.
What happens with my code is that the file is always saved with the last potentiometer value when I started recording.
How can I solve this problem so that the file is formatted:
Voltage
1.12
1.5
2.0
3.0
4.0
3.5
3.0
…
Table table;
void RECORD() {
table = new Table();
table.addColumn("Voltage");
TableRow newRow = table.addRow();
for(int k=0; k<10; k++) {
table.addRow();
newRow.setFloat("Voltage",val_pot2);
saveTable(tabela, "data/new.csv");
delay(10);
}
}