import processing.serial.*;
Serial mySerial;
String val;
int x = 0;
PrintWriter output;
void setup() {
mySerial = new Serial( this, Serial.list()[0], 9600);
output = createWriter( "data.txt" );
output.println("INPUT PROTOTYPE"); //HEADER
}
void draw() {
if (mySerial.available() > 0 ) {
String value = mySerial.readStringUntil('\n'); //Read until new line
if ( value != null ) {
output.println( value );
x++;
}
}
}
void keyPressed() {
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
exit(); // Stops the program
}