Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Written by Lucas Mathias Haasum
- import processing.serial.*;
- PrintWriter output;
- Serial myPort;
- int celsius;
- void setup() {
- size(400,400);
- printArray(Serial.list());
- String portName = Serial.list()[1];
- output = createWriter("temperature.txt");
- myPort = new Serial(this, portName, 9600);
- }
- void draw() {
- background(0, 26, 51);
- textSize(60);
- text(celsius, 200, 200);}
- void serialEvent (Serial myPort) {
- celsius = myPort.read();
- output.println(celsius);
- output.flush(); // Writes the remaining data to the file
- delay(1000);
- }
- void keyPressed() {
- output.flush(); // Writes the remaining data to the file
- output.close(); // Finishes the file
- exit(); // Stops the program
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement