Rywo

exercise 6 processing

Jun 18th, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import processing.serial.*;
  2. Serial myPort;
  3. String sensorReading="";
  4.  
  5. void setup() {
  6. size(400, 400);
  7. myPort = new Serial(this, Serial.list()[2], 9600);
  8. myPort.bufferUntil('\n');
  9.  
  10. }
  11.  
  12. void draw() {
  13. background(255);
  14. fill(0);
  15. text("Sensor Reading: " + sensorReading, 20, 20);
  16. rect(width/2, height/2, float(sensorReading), float(sensorReading));
  17.  
  18. }
  19.  
  20. void serialEvent (Serial myPort) {
  21. sensorReading = myPort.readStringUntil('\n');
  22.  
  23. }
Add Comment
Please, Sign In to add comment