0% found this document useful (0 votes)
102 views17 pages

Keypad and Display Laboratory Instructions

This laboratory involves three parts: 1) Connecting an LCD to an Arduino and displaying a message. 2) Typing a message on a computer and displaying it on the LCD. 3) Connecting a 4x4 keypad to the Arduino and displaying pressed keys on the LCD.

Uploaded by

Boy of Steel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views17 pages

Keypad and Display Laboratory Instructions

This laboratory involves three parts: 1) Connecting an LCD to an Arduino and displaying a message. 2) Typing a message on a computer and displaying it on the LCD. 3) Connecting a 4x4 keypad to the Arduino and displaying pressed keys on the LCD.

Uploaded by

Boy of Steel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

ECEN 106 Laboratory: Keypad and Display

Overview
This laboratory has three parts. First, you will connect a liquid crystal display (LCD) to the Arduino and
display a message. Second, you will type a short message on your computer and display it on the LCD.
Third, you will connect a 4x4 matrix keypad to the Arduino and display its key presses on the LCD.

Background
How Liquid Crystal Displays (LCDs) Work
The screen of LCDs is made of pixels. Text is created using these pixels, and the programmer can control
each individual pixel. Characters are displayed by controlling the pattern of the pixels.

Figure 1

LCDs can be monochrome (mono-colored) or colored. In monochrome LCDs, each pixel can be on or off,
or different shades of gray. In colored LCDs, each pixel can have different colors. The colored pixels can
display red, green, and blue. The three primary colors can be combined to make different colors.

How Keypads Work


Buttons on a keypad are arranged in a matrix of rows and columns. A 3x4 keypad has four rows and
three columns. A 4x4 keypad has four rows and four columns.

Figure 2

Beneath each key is a membrane switch, like those used for many computer keyboards. Each switch in a
row is connected to the other switches in the same row by a conductive trace underneath the pad. The
switches in a column are connected the same way; one side of the switch is connected to all the other
switches by a conductive trace. Each row and column are brought out to a single pin, for a total of eight
pins on a 4x4 keypad.

Figure 3
Pressing a button closes the switch between a column and a row trace, allowing current to flow between
a column pin and a row pin. The Arduino determines which button is pressed by detecting the row and
pin that is connected to the button.

This happens in four steps:

1. When no buttons are pressed, all the column pins are held HIGH, and all of the row pins are held
LOW.

Figure 4

2. When a button is pressed, the column pin is pulled LOW because the current from the HIGH
column flows to the LOW row pin.
Figure 5

3. The Arduino now knows which column the button is in, so now it needs to find the row it is in. It
does this by switching each one of the row pins HIGH, and at the same time reading all the
column pins to detect which column pin returns to HIGH.

Figure 6

4. When the column pin goes HIGH again, the Arduino has found the row pin that is connected to
the button.
Figure 7

Computer keyboards work on the same principle. A simple processor in the keyboard performs the same
function as the Arduino does in this example. It then notifies the computer which key has been pressed.

Required Equipment and Materials


● Computer with Arduino IDE software installed (1)
● LAFVIN Super Starter Kit for UNO R3 (1), containing the following items:
o Arduino UNO with USB Cable (1)
o I2C Enabled 1602 16x2 LCD (1)
o 4x4 Matrix Keypad (1)
o Male-to-Female Jumper Wires (4)
o Male-to-Male Jumper Wires (8)

Part 1: Connect and Test the Liquid Crystal Display (LCD)


In this part of the laboratory, you will connect a liquid crystal display (LCD) to the Arduino and display a
message. These instructions are for the I2C-enabled 1602 which is included in the kit from the BYU-
Idaho Bookstore. It has a small daughter board with a 4-pin connector soldered to the back of the
LCD1602 as shown in Figure 8.
Figure 8

1. Install the LiquidCrystal I2C Library written by Marco Schwartz by following these steps:
a. Download the LiquidCrystal_12C library.
b. From the Arduino IDE, select Sketch > Include Library > Add .Zip Library. Figure 9
demonstrates the path.
Figure 9

c. Navigate to your Download folder and open LiquidCrystal_I2C.zip.


d. Select Sketch > Include Library. LiquidCrystal_I2C will be listed under the heading of
Contributed Libraries. You may have to scroll down to find it. Figure 10 demonstrates the
path.
Figure 10

2. Connect the 1602 LCD to the Arduino Uno by following these steps:

NOTE: The male-to-female jumpers are set together in a ribbon in the kit; you will have to split
the ribbon to complete the next steps.

a. Connect GND on the LCD to GND on the Arduino with a male-to-female jumper.

b. Connect VCC on the LCD to 5V on the Arduino with a male-to-female jumper.

c. Connect SDA on the LCD to A4 on the Arduino with a male-to-female jumper.

d. Connect SCL on the LCD to A5 on the Arduino with a male-to-female jumper.

e. Your connections should look like the diagram in Figure 11:


Figure 11

3. Download and run the sketch by following these steps:

a. Download HelloWorld.ino.

b. Select HelloWorld.ino in your Downloads directory. The popup window titled Moving will
open.

Figure 12

c. Select OK. The Arduino IDE will open, showing the HelloWorld sketch.

d. Select the Upload button, shown circled in red in Figure 13.


Figure 13

e. After the sketch compiles and downloads, the LCD will display the message “Hello, world!
ECEN 106 is fun!” (See Figure 21).

f. If you do not see a message, check your wiring. If you still do not see the message, try turning
the screw on the I2C module on the back of the LCD. The screw controls the brightness of the
display.

Figure 14
g. Edit the sketch to display your first name on the top line and your last name on the bottom
line. While editing the sketch, be sure to leave the quotation marks in the code.

h. Select the download button again to display your name.

i. Take a photo of the display showing your name and submit it in JPG format for your laboratory
report.

Part 2: Send Computer Key Presses to the LCD


In this part of the laboratory, you will type a short message on your computer keyboard and display it on
the LCD.

1. Download and run the sketch by following these steps:

a. Download SerialDisplay.ino.

b. Select SerialDisplay.ino in your Downloads directory. The popup window titled Moving will
open.

Figure 15

c. Select OK. The Arduino IDE will open, showing the SerialDisplay sketch.

d. Select the Upload button.

e. Select the Serial Monitor button, shown circled in red in Figure 16.
Figure 16

f. The console window will open. See Figure 17.

Figure 17

g. Type a short message in the console, then press Enter on your keyboard. The message will
appear on the LCD. See Figure 18 for an example.
Figure 18

Figure 19

h. Take a photo of the display showing your message and submit it in JPG format for your
laboratory report.

Part 3: Connect and Test the 4x4 Matrix Keypad


In this part of the laboratory, you will connect a 4x4 matrix keypad to the Arduino and display its key
presses on the LCD.

1. Install the Keypad Library written by Mark Stanley and Alexander Brevig by following these steps:
a. From the Arduino IDE, select Sketch > Include Library > Manage Libraries. Figure 20
demonstrates the path.

Figure 20

b. When the Library Manager window opens, search for keypad and scroll down to Keypad by
Mark Stanley, Alexander Brevig. See Figure 21 for an example.
Figure 21

c. Select Install. Keypad will be listed under the heading of Contributed Libraries.

2. Connect the 4x4 matrix keypad to the Arduino Uno by following these steps:

a. Connect pin 1 (far-right pin) of the keypad to pin 2 of the Arduino with a male-to-male
jumper.

b. Connect pin 2 of the keypad to pin 3 of the Arduino with a male-to-male jumper.

c. Connect pin 3 of the keypad to pin 4 of the Arduino with a male-to-male jumper.

d. Connect pin 4 of the keypad to pin 5 of the Arduino with a male-to-male jumper.

e. Connect pin 5 of the keypad to pin 6 of the Arduino with a male-to-male jumper.

f. Connect pin 6 of the keypad to pin 7 of the Arduino with a male-to-male jumper.

g. Connect pin 7 of the keypad to pin 8 of the Arduino with a male-to-male jumper.

h. Connect pin 8 (far-left pin) of the keypad to pin 9 of the Arduino with a male-to-male jumper.

i. Your connections should look like the diagram in Figure 22.


8 1

Figure 22

3. Download and run the sketch by following these steps:

a. Download KeyPadDisplay.ino.

b. Select KeyPadDisplay.ino in your Downloads directory. The popup window shown in Figure
23 will open.

Figure 23

c. Select OK. The Arduino IDE will open, showing the KeyPadDisplay sketch.

d. Select the Upload button.


4. Test your configuration by following these steps:

a. Press a key on the 4x4 matrix keypad. The pressed key will appear on the LCD.

b. Make a short video that demonstrates correct operation and submit it in MP4 format for your
laboratory report.

Submit Your Laboratory Report


Submit your two JPG photos and short MP4 video through Canvas. No written report is required.

You might also like