Save TXT
in
Core Library Questions
•
1 year ago
Hello
I'm trying to record values coming from a temperature sensor in a document . TXT but the code I'm using does not write anything ..
thanks
I'm trying to record values coming from a temperature sensor in a document . TXT but the code I'm using does not write anything ..
thanks
- 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, "COM11", 9600);
- // file to store your incoming data
- output = createWriter("teste.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();
- }
1