LCD KEYPAD Shield
/*
* Project name:
LCD KEYPAD Shield
* Copyright
(c) Researchdesignlab.com
* Description:
* Test configuration:
MCU: ATMEGA328
Dev.Board: Arduino uno
Oscillator: 16 MHz
Software: Arduino
*/
/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
// include the library code:
#include <LiquidCrystal.h>
int sensorValue = 0; // value read from the keypad
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensorPin = A0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
delay(2000);
}
void loop() {
lcd.clear(); // clear lcd display
lcd.setCursor(0, 0); // set the cursor to column 0, line 0
lcd.print("LCD KEYPAD Shield");
lcd.setCursor(0, 1); // set the cursor to column 0, line 1
// read the input on analog pin 0 of keypad :
sensorValue = analogRead(sensorPin);
// check if the keypad is pressed disply keypad on lcd using sensorValue .
if(sensorValue<=10)
lcd.print("RIGHT KEY");
else if((sensorValue<=492)&&(sensorValue>=482))
lcd.print("DOWN KEY");
else if((sensorValue<=325)&&(sensorValue>=315))
lcd.print("UP KEY");
else if((sensorValue<=595)&&(sensorValue>=585))
lcd.print("LEFT KEY");
else if((sensorValue<=765)&&(sensorValue>=755))
lcd.print("SELECT KEY");
else
lcd.print("NO KEY PRESSED");
delay(500);
}