Meet One Pin Keypad

by Progetto Company in Circuits > Arduino

1394 Views, 0 Favorites, 0 Comments

Meet One Pin Keypad

Meet the One Pin Keypad! A new Arduino module from Progetto!
One Pin Keypad Instructables.png

DISCLAIMER: THIS IS A USAGE GUIDE FOR AN OPEN SOURCE PRODUCT: THE ONE PIN KEYPAD. THIS IS NOT A DIY PROJECT. IF YOU WANT TO MAKE THE BOARDS YOURSELF, THE EAGLE FILES CAN BE FOUND AT THE END OF THE TUTORIAL.

What is the One Pin Keypad?

One Pin Keypad makes using a matrix keypad so much easier and lets you reserve your precious Arduino I/O for other purposes. A 16 button matrix keypad typically requires 8 digital inputs on an Arduino microcontroller. The most popular Arduinos limit you to only 14 digital pins, so a 16-button keypad leaves you with only 6 pins for the rest of your project. This resource-shortage may lead to a costly design trade-off or a more costly Arduino upgrade.

The One Pin Keypad module eliminates the need for all of these digital inputs. As its name implies, One Pin Keypad uses only one pin (an analog input) plus GND and VCC connections, so wiring your keypad is a snap! The One Pin Keypad Arduino library (included) also simplifies the programming required to process the keypad inputs, saving you more time and effort.

For the Raspberry Pi Usage Guide, click here

Gather Parts!

00100dPORTRAIT_00100_BURST20181014133513999_COVER.jpg
00100dPORTRAIT_00100_BURST20181014220421192_COVER.jpg

To get started with your One Pin Keypad board, you'll need:

  • A One Pin Keypad Board
  • An Arduino of some flavour (An Arduino Nano was used in this case)
  • 3 M/F jumper cables
  • A 16 button membrane keypad
  • Breadboard (Optional), used here since the Arduino Nano is breadboard compatible

Wire It All Together!

00100dPORTRAIT_00100_BURST20181016164749974_COVER.jpg
00100dPORTRAIT_00100_BURST20181016164950661_COVER.jpg
00100dPORTRAIT_00100_BURST20181016170033364_COVER.jpg
00000PORTRAIT_00000_BURST20181016170446408.jpg
00100dPORTRAIT_00100_BURST20181016170833223_COVER.jpg
00100dPORTRAIT_00100_BURST20181016171455505_COVER.jpg
00100dPORTRAIT_00100_BURST20181016172031055_COVER.jpg

The One Pin Keypad requires 3 connections to the Arduino Nano, as follows:

GND to GND

VCC to 5V

AOUT to A0 ( or any other analog pin, just make sure to change it in the example sketch).

Once you've made the connections to the Arduino, connect your membrane keypad, ensure you have the correct orientation see images. To ensure you have it right verify that the coloured (white and black) sections indicating rows and columns above the female connector match up with those in the image.

Install Arduino Library From Github

Github Page.png

The Arduino library for the One Pin Keypad can be found here.

Download the library as a .zip file and follow the steps outlined at these amazing tutorials from Sparkfun here (for Windows) or here (for Mac).

UPDATE 10/30/2018: The Progetto One Pin Keypad Arduino library is now listed in the Arduino Library Manager, see this awesome tutorial (again from Sparkfun) for an easier way to install the library!

Calibrate Your Board

calibrateThresholds.PNG
calibrateThresholds2.PNG
calibrateThresholdsOutput.PNG

For this step, we are going to need the calibrateThresholds example sketch. Plug your Arduino in and use the File menu to open the calibrateThresholds example from the Progetto One Pin Keypad Arduino Library.

Run this sketch and follow the instructions displayed on the Serial Monitor to calibrate your board. After calibration walks through all the buttons, test out your new analog values to see if they work by pressing some buttons when prompted to "Begin.", if the new values prove to be inaccurate, hit the reset button to recalibrate.

The calibration sketch should provide you with 2 lines of code you'll need in the next example, make sure to keep the Serial Monitor open and/or copy them both!

Check Out ReadKeypadWithTimeout!

readKeypadWithTimeout1.PNG
readKeypadWithTimeout2.PNG

Now that your One Pin Keypad board is calibrated, use the File Menu to open the readKeypadWithTimeout example sketch. Remember that analog value array you copied? Replace line 20 (see below) with those newly calibrated analog values.

Example:

// ex: int myThresholds[16] = {calibrated values would be here}

is replaced with this:

int myThresholds[16] = {36, 104, 166, 218, 263, 307, 345, 379, 406, 436, 463, 486, 514, 525, 547, 562};

Next, add the next line of code after line 20, (see below):

keypad.useCalibratedThresholds(myThresholds);

is added after line 20:

// If calibrated values are being used, run useCalibratedThresholds(your array name) below:

making lines 20 and 21 look like this in the end:

// If calibrated values are being used, run useCalibratedThresholds(your array name) below:
keypad.useCalibratedThresholds(myThresholds);

After that's done upload the code and test it out by pressing some buttons! Feel free to adapt the example sketch to your projects! Remember that readKeypadWithTimeout returns the button being pressed as a char and the timeout is set in milliseconds! If you don't want a timeout use the NO_TIMEOUT constant.

How the One Pin Keypad Works

20180929_194434_2 (2).jpg
20180929_194455_2 (2).jpg

Much of the One Pin Keypad's design is based off of Hari Wiguna's implementation of a voltage divider to obtain a unique analog value for each key in a 16 pin keypad. One Pin Keypad's design remains largely the same, with a few tweaks. If you a want a great tutorial on how the One Pin Keypad works, feel free to check out Hari Wiguna's awesome video here!

Conclusion

IMG_20181104_133432.jpg

In this instructable, we covered how to get started with your One Pin Keypad board. Now, the curious among you may have wondered why the readKeypadInstantaneous example sketch was never used, the reason is that it is not as useful, because the button has to be pressed when it is called, the readKeypadInstantaneous() function is used primarily to simplify readKeypadWithTimeout() in the library. If it catches your eye feel free to take it for a spin. Happy Hacking!

If you have any questions, leave a comment below or email us at progettocompany@gmail.com.

All the best,

Progetto Company

P.S. As promised, a link to the board's Eagle Files.

NEW!!! LCD Example Sketches!

IMG_20181108_151057.jpg

UPDATE: 11/8/2018:

We have released LCD example sketches that work with standard 16 x 2 LCD modules!

Hook up an LCD using the tutorial below, load up the readKeypadWithTimeout_LCD example sketch, add your calibrated array just as you would with the regular readKeypadWithTimeout example sketch and watch as the button you pressed appears on screen! Let us know in the comments what you create!

Arduino LCD hookup guide:

https://www.arduino.cc/en/Tutorial/HelloWorld

Remember to use the potentiometer to adjust your contrast!

UPDATE: 12/23/2018:

The LCD example sketches now allow the use of I2C backpacks for the LCDs! They use the library from the link below:

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/

Make sure to run an I2C Scanner sketch to determine the LCDs address:

https://playground.arduino.cc/Main/I2cScanner

Happy Hacking!

John Wolf,

Progetto