Arduino LCD16x2 Shield

LCD16x2 Shield

LCD16x2 shield is an Arduino shield that also comes with 6 buttons. All of the buttons on this shield are connected to the Arduino by using just one GPIO pin. In this tutorial, I will explain how to use LCD16x2 shield with Arduino Uno. This product is compatible with Arduino LCD library (LiquidCrystal.h). There are 5 buttons in this product (up, down, left, right, and select) that can be used for make a project such as display menu items and select them with the buttons.

LCD16x2 shield

The 5 buttons in this product are connected to only single pin (A0), so this will save the use of pins. This technique is called multiplexing. Multiplexing technique can be implemented with multiplexer IC such as 74153, but in this product they use a chain of resistor to do multiplexing. The buttons are connected to a chain of resistors using voltage divider technique.

LCD button ladder

Voltage Divider

The output voltage of the voltage divider circuit is depend on which button is pressed. For example if button 5 (left button) is pressed then the input voltage to the ADC will be 2.47 V. You can calculate this by using voltage divider formula.

Voltage divider circuit

Voltage divider formula

In this case (button left is pressed), the value of R1 is 2K and the value of R2 is 1.95K (330R + 620R + 1K). So if we calculate with the voltage divider formula, the voltage output will be 2.47V. This voltage value can be read by analogRead() function on A0 pin. If we read analog value when the left button is being pressed, then the return value will be about 505 (for 10-bit ADC). 505 is obtained from (2.47V / 5V) * 1024.

Example Code

This is example code for reading all ADC value when every button is pressed. The ADC value will be print to the LCD16x2 along with analog input voltage value and which button is being pressed.

Leave a Reply

Your email address will not be published. Required fields are marked *