Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import processing.serial.*;
  2.  
  3. Serial myPort;
  4. String myText="";
  5.  
  6. void setup(){
  7. size(300, 300);
  8. myPort = new Serial(this, "COM6", 9600);
  9. myPort.bufferUntil('n');
  10. }
  11. void serialEvent (Serial myPort){
  12. myText = myPort.readStringUntil('n');
  13. }
  14.  
  15. void draw(){
  16. background(255,0,0);
  17. //ellipse(155, 100, 100, 100);
  18. fill(0,0,250);
  19. //background(0,255,0);
  20. text(myText, 120, 120);
  21. fill(250,250,250);
  22. myText="Vou de boas!";
  23.  
  24. if(mousePressed && (mouseButton == LEFT)){
  25. myPort.write('1');
  26. myText="Para de apertar!";
  27. textSize(26);
  28. }
  29. if (mousePressed && (mouseButton == RIGHT)){
  30. myPort.write('0');
  31. myText="Melhor!";
  32. textSize(12);
  33.  
  34. }
  35. //delay(1000);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement