In the assignment of this week I'm going to use processing to visualize the data extracted from the Hello.Light board made in
the assignment of Electronic design.In this assignment I designed a serial connection between board and code that generated an interface
able to control the LED on my board and tweeter.
I chose to use the Processing, a development environment and online community, for drawing the data from the input device. And
I used the pressure sensor which I have used in the previous assignment as the input device.I followed the instruction as listed on AS220
and used the laptop touch pad as the input device to write processing code and visualise the output on board in sense of sound and LED. .
Processing is in my opinion a really powerful and neat language. You can easily do some fun stuff and with a basic knowledge of
programming you can get fun applications.
As a beginning, I and started with the example given in the tutorial. However, the sketch failed to take the input reading. The
COM12 port was referred by default in the sketch but it was shown to be busy in my computer. As I have two arduino I connect suhas's board
It get connected to COM 13 by default.which was not working in my laptop. So It was not working then I again change board then it works.
I adjust the code for my hello world board so that the serial output is the number of impulses shown by LED and tweeter
void setup()
{
pinMode(PA1,OUTPUT); // Relay output
pinMode(PA0,INPUT); // DATA from arduino
pinMode(PA3,OUTPUT);// LED output
}
void loop()
{
int val = digitalRead(PA0);
if( val == 0)
{
digitalWrite(PA1,HIGH);
digitalWrite(PA3,HIGH);
}
else
{
digitalWrite(PA1,LOW);
digitalWrite(PA3,LOW);
}
}
And then write for Processing
Serial myPort; // Create object from Serial class
void setup()
{
size(200,200); //make our canvas 200 x 200 pixels big
String portName = Serial.list()[1]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 9600);
}
void draw() {
if (mousePressed == true)
{ //if we clicked in the window
myPort.write('1'); //send a 1
println("1");
} else
{ //otherwise
myPort.write('0'); //send a 0
}
}
I wrote code refer to the related book [1] and ran the code. The portal opened clicking on it led blinked and tweeter is beeping
on each touch or clicked on right button on mouse
Download Arduino Code
Download Processing Code
The video of the visualisation can be accessed here.
|