User Tools

Site Tools


prensf2010:processingreceiver
import processing.serial.*; 

PrintWriter logger;

Integer boxX;
Integer boxY;
Serial port; 

PFont font;
 
void setup(){
  size(400, 400);
  
  rectMode(RADIUS); 
  font=loadFont("AmericanTypewriter-Bold-24.vlw");
  logger=createWriter("log.txt");
  
  // List all the available serial ports in the output pane. 
  // You will need to choose the port that the Arduino board is 
  // connected to from this list. The first port in the list is 
  // port #0 and the third port in the list is port #2. 
  println(Serial.list()); 
  // Open the port that the Arduino board is connected to (in this case #0) 
  // Make sure to open the port at the same speed Arduino is using (9600bps) 
  port = new Serial(this, Serial.list()[0], 9600); 
}
 int ready=0;
 
 void draw(){ 
   background(0);

 }

 void send(){
   println("sending");
   port.write('g');
 }
 
 void keyPressed(){
   logger.flush();
   logger.close();
   port.stop();
   exit();
 }
 void serialEvent(Serial p){
   if(p.read()=='1'){
     send();
   }
 }
prensf2010/processingreceiver.txt · Last modified: 2010/05/27 16:41 by nels_oscar