Product categories

Have You Seen

B0505S-1WR3 MORNSUN Isolated DC - DC Converter

B0505S-1WR3 MORNSUN Isolated DC - DC Converter

Mornsun B0505S-1WR3 DC-DC Isolated ConverterMORNSUN B0505S 1WR3 1 watt, 5 Volts Isolated DC to DC Po..

Rs.106.20 (inc GST)
Rs.90.00 + GST

SKU: 2969 | DAE663
Stock: 100
XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)

XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)

XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)XL1509-Adj E1 Buck DC to DC Converter IC, Ad..

Rs.25.96 (inc GST)
Rs.22.00 + GST

SKU: 3657 | DAF397
Stock: 476

Interfacing LCD & Keypad Shield to Arduino



Want to interface LCD & Keypad to Arduino but don’t want to do all that wiring? Well then this LCD Keypad Shield for Arduino is perfect for you. It has a 16x2 Alphanumeric LCD with white characters & blue backlight. It also has a keypad with 5 switches. In this tutorial we will learn basics of the LCD & keypad shield.

The main reason this Arduino LCD shield is easy to use is because it is fully compatible with the LiquidCrystal Arduino Library. All you have to do is just change the Pin numbers of the LCD from the sample LCD code and you are ready to go.

Another major advantage of this LCD & Keypad Shield is that the switches are all connected to only one ADC channel. That’s right only one pin is required to read which one of the five switches is pressed. The pressed switch can be detected by reading analog value trough a 5 stage voltage divider circuit.  The shield also has onboard contrast control pot. You can also control the back-light intensity or turn it ON & OFF via Arduino.

Compatibility

LCD & Keypad Shield is compatable with following Arduino Boards:

Power Required

The LCD & Keypad Shield requires 5 volt power supply. It worked well when I used external adaptor but while using USB supply it works well most of the time. Sometimes if my PC’s USB is also powering some devices then the current required for the back-light control may decrease also this may cause voltage to drop & the 16x2 Alphanumeric LCD may not work properly. So make sure you are not powering lot of devices via USB port.

LCD & Keypad Shield Pin Allocations

  • A0 : All five Switches (Select, Up,Down, Left, Right)
  • D4 : LCD DB4 
  • D5 : LCD DB5
  • D6 : LCD DB6
  • D7 : LCD DB7
  • D8 : LCD RS
  • D9 : LCD Enable
  • D10: LCD Backlight Control

LCD Interfacing

The LCD is interfaced to the Arduino in 4 bit mode i.e. only four data lines are required for interfacing along with Rs & enable. RW is connected directly to ground.

The LiquidCrystal Library that comes with the official Arduino Distribution software can be used for this LCD shield as well. Want to test it? Just open Hello world Example located at “Files -> Examples -> LiquidCrystal -> HelloWorld” and replace LiquidCrystal lcd(12, 11, 5, 4, 3, 2); with LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 ); load the code and you are good to go.

LCD Backlight Control

Arduino’s D10 pin is connected to backlight so you control the backlight by controlling the D10 pin. So if you set D10 pin HIGH the LCD backlight will be fully ON & by setting it LOW the backlight will be OFF. D10 pin is also capable of PWM i.e. Pulse width Modulation. So using PWM you can vary the intensity of the backlight as per your requirement. 

Want to test backlight control? Open Fading example from “Files -> Example -> 03 Analog -> Fading” In the code replace “int ledPin = 9;” to “int ledPin = 10;” load the code and check out how your LCD’s backlight is controlled. 

Note: Nothing will be displayed on the LCD as this code is just a demonstration for backlight controlling and not for LCD interfacing.

Reading Switches

This is a bit complex to understand. As said earlier all five switches are connected to one Analog pin of the Arduino. This is done by using a chain of resistors that causes different voltage to be received by A0 depending on the switch being pressed. The right hand side image shows the schematic of the keypad section. Here is a list of voltages received on A0 pin as per the switch being pressed:-
  • No Switch Pressed:  5 Volts
  • UP Switch:  0.71V
  • Down Switch: 1.61V
  • Left Switch: 2.47V
  • Select Switch: 3.62V
So if you read the Analog voltage using the “analogRead()” function you can determine which switch has been pressed. Though this method is a bit lengthy and tedious it does leave lot of free pins for other applications.

You can download complete code for testing the “LCD & Keypad Shield” from here.

Written by Amol Shah

Amol Shah

Founder of DNA Technology an Electronic Engineer by choice. Started working on this website as an Hobby and now its a full time venture. Very passionate about Electronics and like to learn new stuff. Want to make DNA Technology one of the best Online Store for Electronics Components in India.
Follow Me Twitter | Facebook | Google Plus | Instagram