Code.ToCompDatalogging History
Hide minor edits - Show changes to output
Added lines 1-39:
By [[~Jeff|Jeff Gray]], March 2008
This processing code takes whatever serial data is coming in from Arduino, and saves it to a text file for local datalogging.
'''Arduino Code'''
[@
import processing.serial.*;
Serial port;
PrintWriter output;
void setup() {
// Open the port that the board is connected to and use the same speed
port = new Serial(this, Serial.list()[0], 9600);
// file to store your incoming data
output = createWriter("datalogged.txt");
}
void draw() {
background(255);
if (0 < port.available()) {
// read it and store it in val
char val = (char)port.read();
output.print(val);
print(val);
}
}
void stop(){
// Writes the remaining data to the file
// and closes it before closing sketch
output.flush();
output.close();
println("Data Saved");
super.stop();
}
@]
This processing code takes whatever serial data is coming in from Arduino, and saves it to a text file for local datalogging.
'''Arduino Code'''
[@
import processing.serial.*;
Serial port;
PrintWriter output;
void setup() {
// Open the port that the board is connected to and use the same speed
port = new Serial(this, Serial.list()[0], 9600);
// file to store your incoming data
output = createWriter("datalogged.txt");
}
void draw() {
background(255);
if (0 < port.available()) {
// read it and store it in val
char val = (char)port.read();
output.print(val);
print(val);
}
}
void stop(){
// Writes the remaining data to the file
// and closes it before closing sketch
output.flush();
output.close();
println("Data Saved");
super.stop();
}
@]