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); int serial_in; void setup() { 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 } void loop() { for (int lcd_cursor=0; lcd_cursor<32; lcd_cursor++) { if (lcd_cursor == 15) lcd.setCursor(0,1); else if (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 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 Test Code ”); lcd.setCursor(0,1); lcd.print(“Press Key:”); Serial.begin(9600); } void loop() { int x; 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); } else if (x < 200) { lcd.print (“Up “); Serial.print(“The value at pim A0 ‘UP key pressed’ is :”); Serial.println(x,DEC); } else if (x < 400){ lcd.print (“Down “); Serial.print(“The value at pim A0 ‘Down key pressed’ is :”); Serial.println(x,DEC); } else if (x < 600){ lcd.print (“Left “); Serial.print(“The value at pim A0 ‘Left key pressed’ is :”); Serial.println(x,DEC); } else if (x < 800){ lcd.print (“Select”); Serial.print(“The value at pim A0 ‘Select key pressed’ is :”); Serial.println(x,DEC); } } |
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.