Advertisement
Guest User

Untitled

a guest
Nov 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. //Written by Lucas Mathias Haasum
  2. import processing.serial.*;
  3.  
  4.  
  5. PrintWriter output;
  6. Serial myPort;
  7. int celsius;
  8.  
  9. void setup() {
  10. size(400,400);
  11. printArray(Serial.list());
  12. String portName = Serial.list()[1];
  13.  output = createWriter("temperature.txt");
  14. myPort = new Serial(this, portName, 9600);
  15. }
  16.  
  17. void draw() {
  18.   background(0, 26, 51);
  19.  
  20.   textSize(60);
  21. text(celsius, 200, 200);}
  22.  
  23. void serialEvent (Serial myPort) {
  24.    celsius = myPort.read();
  25.    output.println(celsius);
  26.    output.flush(); // Writes the remaining data to the file
  27.    delay(1000);
  28.  
  29.  
  30. }
  31.  
  32. void keyPressed() {
  33.   output.flush(); // Writes the remaining data to the file
  34.   output.close(); // Finishes the file
  35.   exit(); // Stops the program
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement