Sign up ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I used the code below to save output from an Arduino Uno to a text file.

The problem is whenever I run the code the old data in the text file is deleted.

I don't want the old data to be deleted, what should I change?

import processing.serial.*;
Serial mySerial;
PrintWriter output;
void setup() {
   mySerial = new Serial( this, Serial.list()[0], 9600 );
   output = createWriter( "data.txt" );
}
void draw() {
    if (mySerial.available() > 0 ) {
         String value = mySerial.readString();
         if ( value != null ) {
              output.println( value );
         }
    }
}

void keyPressed() {
    output.flush();  // Writes the remaining data to the file
    output.close();  // Finishes the file
    exit();  // Stops the program
}
share|improve this question

migrated from electronics.stackexchange.com Mar 18 at 15:13

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

1  
See this SO answer for an example. – Roger Rowland Mar 18 at 7:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.