Assignment 4

Using the photo register to trigger an event response on screen


<back

a4.gif
The output on screen
//Assignment 4: Response of photoregister on screen

import processing.serial.*;
int val =0;

Serial port;

void setup()
{
size(400,400);
background(#FFFFFF);
frameRate(10);
println(Serial.list());
port = new Serial(this, Serial.list()[2], 9600);
strokeWeight(5);
}

void draw()
{
  val = port.read();
  //print(val);
  if(val <0)
  {
    background(#ffffff);

    line(50,200,250,200);
  }
  if(val >0)
  {
    background(#ffffff);
    line(50,100,250,100);
  }
}

<back

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License