Saturday, April 14, 2012

Week 12

Date : 9th -13th April 2012


My programming protocol for this project is quite simple. For the LCD that attached to the EOG box, I use voltmeter programming where the output voltage from both horizontal and vertical movement will be displayed on the LCD.

For example:


// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// variables for input pin and control LED
int EOG1 = 1;
int EOG2 = 2;
float vout1 = 0.0;
float vout2 = 0.0;

// print result to lcd display
lcd.setCursor(0, 0);
lcd.print("EOG Vert=");
lcd.setCursor(10, 0);
lcd.print(vout1);
lcd.print("V");
lcd.setCursor(0, 1);
lcd.print("EOG Hori=");
lcd.setCursor(10, 1);
lcd.print(vout2);
lcd.print("V");
delay(500);
}

For wireless communication, I have set both XBee to communicate to each other, and those data transferred can be monitored in the laptop by using XCTU software.

XCTU Monitor

Next, would be the programming for the mouse cursor. Part of the program is as below:


const int buttonPin = 2; //LOW on digital pin enables mouse
const int potXPin = 4; // analog pins for pots
const int potYPin = 5;
void setup()
{
Serial.begin(9600);
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, HIGH); // turn on pull-ups
}
void loop()
{
int x = (512 - analogRead(potXPin)) / 4; // range is -127 to +127
int y = (512 - analogRead(potYPin)) / 4;


For both programming, my references are form MyDuino websites, and mouse serial programming related websites.

No comments:

Post a Comment