Simple Button Keypad – Microcontroller

Simple method for creating a custom button keypad that doesn’t require separate hardware.  Just your microcontroller buttons a few resistors.

What we have here is 9 buttons and 6 signal lines (3 inputs, 3 outputs).  The basic setup is in a grid pattern where the three input lines come down as columns (PIN0, PIN1, and PIN2),  and the three output lines come across as rows (PIN3, PIN4, and PIN5).
Simple Button Keypad - MicrocontrollerEach button is a momentary ON button, normally open.  So what will happen is when we press the button it will make a connection between that button’s input and output, other wise there is no connection.

The key here is in the software.

What the software is going to do is sweep between the inputs and outputs, for every combination very fast.  I will outline the steps for 1 input, and then it simply repeats the same steps for each other input.

For input on PIN0
— PIN0, 1, 2 defined as outputs
— PIN3, 4, 5 defines as inputs
Simple Button Keypad - Microcontroller Schematic1. Set PIN0, PIN1, AND PIN2 to LOW
2. Set PIN0 to HIGH
3. Check if PIN3 is HIGH or LOW, IF HIGH go to function SW1
4. Check if PIN4 is HIGH or LOW, IF HIGH go to function SW4
5. Check if PIN5 is HIGH or LOW, IF HIGH go to function SW7
6. Set PIN0 to LOW

This will then repeat with the only differences being which input pin is set to HIGH, and the names of the SW functions its going to.
For more detail: Simple Button Keypad – Microcontroller

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter