Week 15: Interface and application Programming

In this assignment i wanted to integrate my final project. I created a graphic interface that responds that interacts of my sensor, IR Motion Sensor. This one has an adjustable delay before firing (approx 2-4 seconds). Digital signal output is 3.3V high/low. Sensing range is about 7 meters (120 degree cone). It's perfect sensor for the LED lamp controlled by my Fabduino.

I have used my board Fabduino, where I had already loaded the scketch of the sensor for light the led of my lamp.
The first step was to download the software Processing .

The first command is to communication with the serial port. Processing is not a softwwre that generally makes graphics you can also interact with other devices, but we have to seprate call in this case with a command. The command is import, import a library. The name that you do serial port. The port that communicates with our Arduino is n. 6. I initialize it and give him a value of 50 diameter. Imposed then the values in the first block, void setup, as background and diameter. In the second block Void Draw, we give the conditions to run at infinite loop

This is the original code.

/**
* Phototransistor Input to Circle
*
* Read data from the serial port and changes the fill and stroke color of a circle
* relative to the values recieved from the sensor.
* Circle fill and stroke are random, unless a sensor value below 200 is recived.
*/

//import serial library
import processing.serial.*;

Serial serialPort;
int diameter= 200;

void setup() {
size(500, 500);
background(#60b246);
stroke(255);
smooth();
println(Serial.list());
serialPort = new Serial(this, Serial.list()[5], 9600);
}

void draw() {
while (serialPort.available () > 0) {
int lightIn = serialPort.read();
diameter=diameter*lightIn
if (lightIn == '1') {
println("motion on");
redraw();
}
else{
println("motion off");
redraw();
}

ellipse(250, 250, diameter, diameter);
}

}

It reads the value that comes from the serial port, the pin number 7 we have a sensor, an input device that works repeat that if movement is to print 1.
 If it does not read zero movement must print.
On the other side if you read the value "1" diameter will be 200 and the edge and fill will be zero. If the value is other than "1" diameter is 50 with the red fill and red border.

(Processing file)