LCD KEYPAD Shield-Serial
/*
* Project name:
LCD KEYPAD Shield-Serial
* Copyright
(c) Researchdesignlab.com
* Description:
* Test configuration:
MCU: ATMEGA328
Dev.Board: Arduino uno
Oscillator: 16 MHz
Software: Arduino
*/
/*
Analog input, analog output, serial output LCD Display
code(HEX) Command to LCD
0X01 clear the LCD Display screen
0X80 Force the cusor blink on 1st line
0XC0 Force the cusor blink on 2st line
*/
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
delay(1000);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// check if the keypad is pressed disply keypad on lcd using sensorValue .
if(sensorValue<=10)
{
Serial.write(byte(0X01));
Serial.write(byte(0X80));
Serial.print("RIGHT KEY");
}else if((sensorValue<=492)&&(sensorValue>=482))
{
Serial.write(byte(0X01));
Serial.write(byte(0X80));
Serial.print("DOWN KEY");
}
else if((sensorValue<=325)&&(sensorValue>=315))
{
Serial.write(byte(0X01));
Serial.write(byte(0X80));
Serial.print("UP KEY");
}
else if((sensorValue<=595)&&(sensorValue>=585))
{
Serial.write(byte(0X01));
Serial.write(byte(0X80));
Serial.print("LEFT KEY");
}else if((sensorValue<=765)&&(sensorValue>=755))
{
Serial.write(byte(0X01));
Serial.write(byte(0X80));
Serial.print("SELECT KEY");
}
else
{
Serial.write(byte(0X01));
Serial.write(byte(0X80));
Serial.print("NO KEY PRESSED");
}
delay(1000);
}