Advertisement
Guest User

Untitled

a guest
Apr 14th, 2017
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. // www.jbcse.com
  2.  
  3. import processing.serial.*;
  4.  
  5. Serial myPort;  // Create object from Serial class
  6.  
  7. int x = 0;
  8. int y = 0;
  9.  
  10. void setup(){
  11.   size(320, 240);
  12.   println((Object)Serial.list());
  13.   String portName = Serial.list()[1];
  14.   myPort = new Serial(this, portName, 460800);
  15. }
  16.  
  17. void draw(){  
  18.   while ( myPort.available() > 0) {  // If data is available,  
  19.  
  20.     set(x, y, color((byte)(myPort.read()) & 0xFF));
  21.     x++;
  22.     if(x == 320){
  23.       x = 0;
  24.       y++;
  25.       if (y == 240){
  26.          y = 0;
  27.          background(127);
  28.       }
  29.     }
  30.   }
  31. }
  32.  
  33. void keyPressed(){
  34.   if (key == 's' || key == 'S')
  35.     saveFrame("frame-####.bmp");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement