How to Use Arduino LCD Keypad Shield with 16x2 Display and Buttons
How to Use Arduino LCD Keypad Shield with 16x2 Display and Buttons
The LCD Keypad Shield is an add-on board for Arduino UNO that combines a 16-character by 2-line LCD display (16x2) with 6 push buttons on a single board. This makes it easy to show data and receive user input without additional wiring.
![Arduino LCD Keypad Shield mounted on Arduino UNO displaying initial text message]
Required Components
- Arduino UNO R3
- USB cable for code upload
- 1602 LCD 16x2 Keypad Shield (choose Blue or Yellow screen as preferred)
- Power Adapter 9V 2A (optional, for standalone operation without USB)
Hardware Assembly
Follow these steps to install the hardware:
- Place Arduino UNO R3 on a flat, stable surface
- Align the pins of the LCD Keypad Shield with the headers on Arduino UNO
- Press the Shield down firmly until all pins are fully seated
[Draw a diagram showing Shield alignment with Arduino UNO headers with arrows pointing to matching pin positions]
Code for Display Output and Button Reading
Since the original source did not include code examples, here is a working sketch based on the standard operation of the LCD Keypad Shield:
// Arduino LCD Keypad Shield - LCD Display and Button Reading
#include <LiquidCrystal.h>
// LCD pin assignment (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// Analog pin for reading buttons
const int buttonPin = A0;
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LCD Keypad Shield");
lcd.setCursor(0, 1);
lcd.print("Press any button");
}
void loop() {
int buttonValue = analogRead(buttonPin);
String buttonName = getButtonName(buttonValue);
lcd.setCursor(0, 1);
lcd.print(" "); // Clear the button name line
lcd.setCursor(0, 1);
lcd.print(buttonName);
delay(100);
}
String getButtonName(int value) {
// ADC thresholds for each button (adjust according to your board)
if (value < 100) {
return "Right ";
} else if (value < 200) {
return "Up ";
} else if (value < 400) {
return "Down ";
} else if (value < 600) {
return "Left ";
} else if (value < 800) {
return "Select";
} else {
return "None ";
}
}
Point to adjust: The ADC threshold values in the getButtonName() function may not match your specific Shield. Open the Serial Monitor and observe the values displayed when pressing each button, then adjust the numbers in the if conditions accordingly.
Upload Process
- Open Arduino IDE and paste the code above
- Go to Tools -> Port and select the port connected to Arduino UNO
- Go to Tools -> Board and select Arduino UNO
- Click the Upload button (right arrow icon)
- Wait for the message “Upload complete” to appear at the bottom of the window
[Draw a diagram showing Arduino IDE menus with arrows pointing to Port and Board selection options]
Expected Result
Once uploaded successfully, the LCD will show “LCD Keypad Shield” on the top row and “Press any button” on the bottom row. Pressing any button will change the bottom row to display the button name: Right, Up, Down, Left, Select, or None (when no button is pressed).
[Draw an illustration showing LCD Keypad Shield display in two states - top row shows project name, bottom row shows pressed button name]
Summary
The LCD Keypad Shield is suitable for projects that need to display status information and receive user commands, such as mode selection menus or displaying sensor readings with button confirmation. The main advantages are easy installation without extra wiring, and the Shield stacks on top of Arduino without blocking most Digital pins, making it convenient to add sensors or motors alongside the display.
Reference Video
อยากทำโปรเจคแบบนี้?
รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน
If you need Arduino project service or urgent IoT development, see full service details on the home page
จ้างทำโปรเจคเลย