Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import processing.serial.*;
  2.  
  3. Serial myPort; // Create object from Serial class
  4. String val; // Data received from the serial port
  5.  
  6. void setup() {
  7. size(200, 200);
  8.  
  9. // I know that the first port in the serial list on my mac
  10. // is Serial.list()[0].
  11. // On Windows machines, this generally opens COM1.
  12. // Open whatever port is the one you're using.
  13. println(Serial.list());
  14. String portName = Serial.list()[1]; //change the 0 to a 1 or 2 etc. to match your port
  15. myPort = new Serial(this, portName, 9600);
  16. }
  17.  
  18. void draw() {
  19. if (mousePressed == true)
  20. { //if we clicked in the window
  21. myPort.write('1'); //send a 1
  22. println("1");
  23. } else
  24. { //otherwise
  25. myPort.write('0'); //send a 0
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement