In this tutorial we are going to interface a 4×4 (16 key) keypad with ARDUINO UNO. We all know keypad is one of the most important input devices used in electronics engineering. Keypad is the easiest and the cheapest way to give commands or instructions to an electronic system. Whenever a key is pressed in keypad module the Arduino Uno detects it and shoes the corresponding key on 16×2 LCD. [Also check: Keypad Interfacing with 8051 Microcontroller]
Components Required
Hardware: ARDUINO UNO, power supply (5v), 100uF capacitor , buttons (two pieces), 1KΩ resistor (two pieces), 4×4 Keypad Module, LED, JHD_162ALCD (16x2LCD).
Software: arduino IDE (Arduino nightly).
Circuit Diagram and Working Explanation
In 16×2 LCD there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins. One can power or leave the back light pins. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS&VDD or GND&+5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown) and 3 control pins (RS&RW&E).
In the Arduino uno keypad interfacing circuit, you can observe that I have only took two control pins. This give the flexibility of better understanding, the contrast bit and READ/WRITE are not often used so they can be shorted to ground. This puts LCD in highest contrast and read mode. We just need to control ENABLE and RS pins to send characters and data accordingly. [Also check: 16×2 LCD Interfacing with Arduino Uno]
The connections which are done for LCD are given below:
PIN1 or VSS to ground
PIN2 or VDD or VCC to +5v power
PIN3 or VEE to ground (gives maximum contrast best for a beginner)
PIN4 or RS (Register Selection) to PIN8 of ARDUINO UNO
PIN5 or RW (Read/Write) to ground (puts LCD in read mode eases the communication for user)
PIN6 or E (Enable) to PIN9 of ARDUINO UNO
PIN11 or D4 to PIN10 of ARDUINO UNO
PIN12 or D5 to PIN11 of ARDUINO UNO
PIN13 or D6 to PIN12 of ARDUINO UNO
PIN14 or D7 to PIN13 of ARDUINO UNO
We are going to connect the keypad module between pins 0-7 of Arduino Uno, as shown in the circuit diagram. All the eight pins of keypad module are connected accordingly.
Read More: Keypad Interfacing with Arduino Uno