SOLVED //Save data from serial Arduino to txt using Processing

edited November 2017 in Arduino

Hey guys,

I'm working on a program that saves data from my potentiometer to a txt file. The idea is that I have my potentiometer on analog A0 and every second the value of the analog port has to be saved in Processing in a file. After a minute, the data has to be saved in another file. So I actually have to build something that saves 60 values per minute. And added to that, the data in the file has to have the actual time behind it.

For Arduino I have to use Firmata.

My processing code for now :

import processing.serial.*;
import cc.arduino.*;          //this is all double, but I don't know which to use
Arduino arduino;
Serial pot;

void setup() {
//println(Serial.list());
//pot = new Serial(this, Serial.list()[0], 9600);    //should I use Serial or Arduino?


println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 57600);
PrintWriter output;
output = createWriter("data.txt");
output.println(arduino.analogRead(0));  //in the file it only prints 0
output.flush();
output.close();
}

void draw() {}

Yes, I know this code is far from finished. That's why I have come here, for your help. I put some things in the code, I hope you can answer those questions. And I need some help with creating a new file after 1 minute.

Tagged:

Answers

Sign In or Register to comment.