Interface and Application Programming
Introduction:
In the Interface and application programming.I am using arduino board and Arduino IDE with my FTDI board designed in the assignment number six.also Using processing open sourse software to for implementing mouse click event to control my LED blink through the Proceesing
First i implemented FTDI with echo message from FTDI connector but as Francisco suggested me i used the processing and arduino to implement the Processing to my Button+LED board through the Arduino
I took Arduino board and installed Arduino IDE in my PC. and also installed processing made COM3 port as serial communication port enable.following window shows the program i adopted for pin no. 13 on my program and uploading this program on my arduino board atmega328P chip.
Figure.1
char val; // Data received from the serial port
int ledPin = 13; // Set the pin to digital I/O 13
void setup() {
pinMode(ledPin, OUTPUT); // Set pin as OUTPUT
Serial.begin(9600); // Start serial communication at 9600 bps
}
void loop() {
if (Serial.available())
{ // If data is available to read,
val = Serial.read(); // read it and store it in val
}
if (val == '1')
{ // If 1 was received
digitalWrite(ledPin, HIGH); // turn the LED on
} else {
digitalWrite(ledPin, LOW); // otherwise turn it off
}
delay(10); // Wait 10 milliseconds for next reading
}
Then in Processing window which almost look like arduino IDE following figure shows the Processing window with program, its program for window 200*200 pixel size child window it will create on execution of given program
Figure.2
First I programmed my arduino with above given program as its LED will glow then in processing run the program, one child window will open where i m going to just click with mouse whenever mouse event will generate an event this will glow the target board designed in assignment no. six and this is what i supposed to do in the assignment and following the tutorial on the google for interface assignment
Figure.3
Program for processing is given below It was really fun to do all interfacing.I did interfacing successfully.I faced problem in setting up baud rate initially because of baudrate then i changed baudrate in the processing and arduino IDE.
import processing.serial.*;
Serial myPort; // Create object from Serial class
void setup()
{
size(200,200); //make our canvas 200 x 200 pixels big
String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 9600);//Change baudrate according to requirement
}
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
}
}
Following figure shows the connection from arduino to the Button LED board.The output of the pin no.13 is given to the preset(button)So The processing window mouse event generated handled by giving output to the button and now window with mouse click interfaces with the Button LED board.
Figure. 4
following link nevigate to working of the interfacing using arduino
Video Link
Arduino text file
processing tex file
Link of previous trial using FTDI echo