This tutorial is to explain how to use a 16×2 character LCD Keypad Shield on Arduino board.
1. Introduction:
The 16X2 LCD Keypad Shield build for Arduino UNO, MEGA, Leonardo and other microcontrollers. This shield is fully compatible with Arduino 4-bit “LiquidCrystal” library.
It includes 16X2 LCD display with 6 push Buttons, among which 5 are connected with A0 analog input through resistor to give different voltage for each buttons and saving on input/output pins. And Pins 4, 5, 6, 7, 8, 9 and 10 are used to interface with the LCD.
1.1: Specification:
- Operating Voltage:5V
- 5 Push buttons.
- RST button to reset arduino program.
- Integrate a potentiometer for adjusting the backlight.
- Expanded available I/O pins.
- Blue light with white characters.
1.2 Buttons functionality:
5 buttons Select, Up, Down, Left and Right are connected with Analog input A0 with a series of Resistance.
If no button is pressed the voltage on A0 will be pulled up to 5V by the 2K resistor called R1. In that situation none of the other resistors have any effect at all, and the analog reading on A0 will be hard on the upper limit of 1023.
When the “UP” button will be pressed, the 2K resistor that is trying to pull it up to 5V, and the 330R that are trying to pull it down to 0V. The voltage presented to A0 in that case is about 0.71V, So if you read a value about 145 from A0 you know the “UP” button is being pressed.
When “Down” button is pressed, (Series Resistor 330R+620R) 950 are trying to pull it down to 0V. then A0 presents 1.61V, value about 329.
2. Required Hardware:
S.No. | Item | Quantity |
1. | Arduino | 1 |
2. | LCD Keypad Shield module | 1 |
3. | Male to Female Jumper Wires | 12 |
3. Building Circuit
Do not changed digital pin 10. This pin is used to control the back light of the LCD.
4. Library File
Following library will be required to run this sketch. Download the zip file extract the same and copy this to your Arduino library folder.
This library file should be placed at the install folder of Arduino. I have a 64 bit Win7 OS and my arduino library folder address is located at
C:\Program Files (x86)\Arduino\libraries
You may download library file from here.
5. Programming:
Once the circuit part is done, Arduino is needed to be programmed. Here is the code to get display on LCD.
You may download this code (Arduino Sketch) from here.
//Robo India's tutorial on LCD Keypad Shield https://www.roboindia.com/tutorials/ #include <Wire.h> #include <LiquidCrystal.h> LiquidCrystal lcd( 8,9,4,5,6,7 ); //interfacing pins void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.setCursor(0,0); lcd.print("LCD Key Shield"); lcd.setCursor(0,1); lcd.print("Press Key:"); } void loop() { int x; x = analogRead (0); lcd.setCursor(10,1); if (x < 60) { lcd.print ("Right "); } else if (x < 200) { lcd.print ("Up "); //analog voltage 145 } else if (x < 400){ lcd.print ("Down "); //analog voltage 329 } else if (x < 600){ lcd.print ("Left "); //analog voltage 585 } else if (x < 800){ lcd.print ("Select"); //analog voltage 741 } }
6. Output
After Uploading the code, LCD will display the text as shown in above image. If you press Right Push button, Right text will display on LCD.
7. Troubleshooting
If you have trouble with display, try rotating the on-board preset.
Still you have trouble, then try attaching a power supply of around 7 to 9Vdc to the 2.1mm DC jack on the Arduino.
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
https://roboindia.com