In this illustration we will going to wire the 16X2 LCD Keypad Shield build for Arduino UNO, MEGA, Leonardo, this board has 4 bit Arduino LCD Library. The keypad shield has select left, up, down and right push button apart from the reset button, the screen contrast adjustment is done by a 10k trimpot potentiometer at the top left corner.
The Liquid Crystal LCD 8 / 9 / 4 / 5 / 6 / 7
The buttons are connected only to A0 analog input through resistor to give different voltage for each buttons and saving on input/output pins. The PIN 0 RX, PIN 1 TX, PIN 2, 3, 11, and 13 are extended to accommodate other external devices, and the rest are used for LCD Shield connections. Please see the diagram below.
For testing the LCD Shield
Before you start upload and running your code you need to import the LiquidCrystal code library located Under the File Example – / LiquidCrystal |
Upload the sketch code to the result display Hello World with counting on the LCD. Try to modify the code and experiment on it.
Arduino Sketch Code wihtout Keypad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <LiquidCrystal.h> //Import Code Library
LiquidCrystal lcd(8,9,4,5,6,7);
intserial_in;
voidsetup()
{
lcd.begin(16,2);// Dimention of the LCD
lcd.print(”www.14core.com“);// display text to the LCD
lcd.setCursor(0,1);// To set lcd.setCursor (column,row)
lcd.print(”Testing the Code below”);
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
Serial.begin(9600);// Opening the serial port baud rate 9600 baud rate
}
voidloop()
{
for(intlcd_cursor=0;lcd_cursor<32;lcd_cursor++)
{
if(lcd_cursor==15)lcd.setCursor(0,1);
elseif(lcd_cursor==31)lcd.home();
while(!Serial.available());// wait until there is signal from computer
serial_in=Serial.read();// Receive signal in ASCII
lcd.write(serial_in);
}
}
Arduino Sketch Code With Keypad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7);// initialize the library with the numbers of the interface pins
voidsetup(){
// 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 Test Code”);
lcd.setCursor(0,1);
lcd.print(“Press Key:”);
Serial.begin(9600);
}
voidloop(){
intx;
x=analogRead(0);
lcd.setCursor(10,1);
if(x<100){
lcd.print(“Right“);
Serial.print(“The value at pim A0‘Right key pressed’is:”);
Serial.println(x,DEC);
}
elseif(x<200){
lcd.print(“Up“);
Serial.print(“The value at pim A0‘UP key pressed’is:”);
Serial.println(x,DEC);
}
elseif(x<400){
lcd.print(“Down“);
Serial.print(“The value at pim A0‘Down key pressed’is:”);
Serial.println(x,DEC);
}
elseif(x<600){
lcd.print(“Left“);
Serial.print(“The value at pim A0‘Left key pressed’is:”);
Serial.println(x,DEC);
}
elseif(x<800){
lcd.print(“Select”);
Serial.print(“The value at pim A0‘Select key pressed’is:”);
Im having problems connecting the LCD 16×2 Keypad Shield to a Wemos D1 V2 board. I think it is the pin assignment. Can you offer any code for that setup? I want to use it to use API to get local weather via wifi.
I think you need to modify the board itself and remap the pins. I suggest to make your own custom shield with 16×2 LCD on i2C and place 4 tactile buttons for UP, DOWN, LEFT, RIGHT. you can drive your LCD in 2 wire SCL, SDA. then attach DHT11 or DHT12 for the sensor.
I have a Arduino nano and want to connect the LCD Keypad Shield to it. Do you know how to wire it?
I have seen some posts about it, but it didn’t work.
Most of LCD Keypad shield communicates using SPI or i2C to your MCU, just verify the pin-outs. :) however, for the push button you still use the same pins which is indicated to shield.
We use cookie to provide you the best possible experience, this site uses cookies and by continuing to use the site you agree that we can save them on your device. Cookies are small text files which are placed on your computer and which remember your preference / some details of your visit. Our cookies don’t collect any personal information. For information, please read our Privacy Statement and Cookie Policy , which also explains how to disable this option in your browser. Cookie SettingsACCEPT
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are as essential for the working of basic functionalit...
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
Im having problems connecting the LCD 16×2 Keypad Shield to a Wemos D1 V2 board. I think it is the pin assignment. Can you offer any code for that setup? I want to use it to use API to get local weather via wifi.
I think you need to modify the board itself and remap the pins. I suggest to make your own custom shield with 16×2 LCD on i2C and place 4 tactile buttons for UP, DOWN, LEFT, RIGHT. you can drive your LCD in 2 wire SCL, SDA. then attach DHT11 or DHT12 for the sensor.
you can used this library below>
http://www.14core.com/wp-content/uploads/2017/03/ESP8266WiFi.zip
http://www.14core.com/wp-content/uploads/2017/03/ESP8266WebServer.zip
http://www.14core.com/flashing-upgrade-eps8266-v1-firmware-with-espressif-flash-tool/
http://www.14core.com/wiring-the-esp8266-12e-remote-soil-moisture-temperature-humidity-monitor/
I have a Arduino nano and want to connect the LCD Keypad Shield to it. Do you know how to wire it?
I have seen some posts about it, but it didn’t work.
Most of LCD Keypad shield communicates using SPI or i2C to your MCU, just verify the pin-outs. :) however, for the push button you still use the same pins which is indicated to shield.