LCD Keypad Shield

Article thumbnail

Published

arduino shields

Using the LCD Keypad Shield's display, backlight, and buttons with Arduino

The LCD Keypad Shield

DFRobot LCD Keypad Shield

LCD keypad shield LCD keypad shield

The LCD Keypad shield contains a 1602 LCD connected to pins 4-9 and backlight connected to digital 10. It also has 6 buttons, 5 of which are connected to A0. The sixth is a reset button.

Arduino Pin Connections

Printing Text

After running the code, it may seem like nothing is displayed. This is because of the contrast adjustment trimpot, which is blue with a gold screw and located in the top left corner of the shield.

To adjust this trimpot, get a flat screwdriver and rotate the screw. Note that this is a precision trimpot, so it can take a few turns to reach the proper value.

Once properly adjusted, you should see the words “Hello, world!” displayed on the screen.

Controlling the Backlight

The LCD’s backlight is connected to digital pin 10. It can be controlled like a normal LED with pinMode and digitalWrite.

Controlling the backlight has many useful applications. For example, the backlight could turn off if there is no user interaction for a long time to implement a power-save mode, similar to a cell phone.

Using the Buttons

The shield contains six buttons, five of which are connected to A0. Each switch is connected to a resistor with a unique value. This is resistor ladder and saves pins by connecting multiple buttons to one analog input.

When pressed, each button generates a different value on the A0 pin. This is how we can know when a button is pressed, as well as which button it is.

The analog input values for each button are:

Notice how each button has a range, not a specific value. This is because resistors have a tolerance, so the actual value of a resistor can vary between parts.

We can compare these ranges with the analog input value to interpret each button press.