LED Bar Graph and Keypad

Last updated May 2019

Introduction

Welcome to ProteShea – in this tutorial, we’ll be interfacing a LED bar graph and keypad to the Arduino Uno (revision 3). This is slightly different from Project 1, in which we showed connecting to a switch array and used more of the LED bar graph. We’ll need four outputs from the Uno to drive four columns of the keypad. In total, we’ll need 8 digital outputs and 4 digital inputs on the Uno. Let’s get started!

Disclaimer

ProteShea, LLC is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com

Some links may be affiliate links, in which ProteShea, LLC earns a commission if you use that affiliate link. Please note that this is at no additional cost to you and helps us in creating more content.

Here’s what you’ll need to get started:

LED Bar Graph

Please see Arduino Uno Rev3 Project 1 to learn more about the LED Bar Graph and how to wire the 470 ohm resistor array in series with each LED.

16-Key Matrix Keypad

The keypad consists of 16 keys with numbers 0-9, letters A-D, an asterisk, and a pound symbol. The keypad consists of 4 columns and 4 rows. We will drive the 4 columns and read the 4 rows to determine what key is pressed. The layout and internal circuitry of the keypad is below. The pinout may vary, but this is how the pins are marked on my keypad.

Layout and Internal Circuitry of Keypad

To determine if a key is pressed, we first have to cycle each column high in sequential order, then check to see if each row output went high. For example, we’ll set column 1 high, then check if keys 1, 4, 7, or * is pressed. Once that check is done, we set column 1 low, then set column 2 high. When column 2 is high, we check if 2, 5, 8, and 0 is pressed, and so on.

Cycling Through Each Column

Each row will be connected to a pull-down resistor, so when the key is not pressed, the Uno will read 0V on its input. When the key is pressed, +5V gets routed to the Uno’s input. For example, when column 1 is high and key 1 is pressed, +5V will get routed to row 5. A video is shown below to show what happens.

What Happens when Key 1 Gets Pressed

Wiring

First, let’s place the LED bar graph and keypad onto the breadboard (if using a breadboard instead of Modulus). With reference to the image below, insert the bar graph so that the body is over the valley of the breadboard. You do not want the pins to short each other by being connected to the same node. Next, place the 470 ohm resistor array on the cathode side of the LED and tie pin 1 of the array to GND. Make sure that pin 1 of the resistor array is not connected to any of the cathodes of the LED bar graph. By plugging in the resistor array, you now have a resistor connected in series with each of the four LEDs. 

Next, use a M/M jumper to wire the anode side of the LED bar graph as outputs to the Uno pins 8-11. For example, pin 7 of the bar graph will get wired to Uno pin 8, pin 8 of the LED will get wired to Uno pin 9, and so on.

Place the 1.2k ohm resistor array as shown in the image below. Tie pin 1 of the array to GND, and make sure it does not connect to any of the pins on the keypad. The breadboard holes outlined in blue-grey will be tied to Uno pins 0-3. For example, pin 1 (column 1) on the keypad will be wired to pin 0, pin 2 (column 2) on the keypad will get wired to pin 1, and so on. The breadboard holes outlined in yellow get routed to Uno pins 4-7. For example, pin 5 (row 1) on the keypad will be wired to pin 4, pin 6 (row 2) on the keypad will get wired to pin 5, and so on.

Circuit Schematic

FuelCan Setup

I placed the breadboard in the bottom storage compartment to limit the length of the jumper wires and mounted the Arduino Uno to the FuelCan’s prototyping area. We need to supply +5V and GND to the power and ground rails on the breadboard. Use the provided banana jack to test-lead clip cables to do so. You will need two male header pins to mount the test-lead clips to the breadboard side. Plug the Type A side of the USB cable into the USB1 receptacle and the Type B side into the Uno’s receptacle, as shown in the animation. Power up the FuelCan with the AC-DC power adapter.

The figure below shows the final system for interfacing a LED bar graph and keypad to the Arduino Uno.

For additional information about the Fuelcan-910, click here or download the user guide.

Plugging in the Type A to Type B USB Cable
Complete Setup

Software

Once the wiring is complete and the FuelCan is powered up, we can now load the sketch onto the Uno. The sketch is below. The table below shows how we mapped each key to a binary number.

Key Mapping to Binary Number

About Author

Eric Shea is the founder of ProteShea and is an electrical engineer. He wishes to have a major impact on bridging the gap between engineering theory and real-world applications. He has worked at Kratos Defense, SpaceX, Air Force Research Laboratory, and Polaris Industries. He received a M.S. in electrical engineering from the University of Pittsburgh and a B.S. in electrical engineering from the University of Florida.

Categories

About Author

Eric Shea is the founder of ProteShea and is an electrical engineer. He wishes to have a major impact on bridging the gap between engineering theory and real-world applications. He has worked at Kratos Defense, SpaceX, Air Force Research Laboratory, and Polaris Industries. He received a M.S. in electrical engineering from the University of Pittsburgh and a B.S. in electrical engineering from the University of Florida.

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on google
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
ProteShea

Learn. Apply. Create.

290 NW Peacock Blvd #880143
Port Saint Lucie, FL 34988