Keypads are a great way to let users interact with your project. You can use them to navigate menus, enter passwords, and control games and robots.
In this tutorial, I’ll show you how to setup a keypad on the Arduino. First I’ll explain how the Arduino detects key presses, then I’ll show you how to find the pinout of any keypad. As a simple example, I’ll show you how to print out the key presses on the serial monitor and an LCD. Finally, I’ll show you how to activate a 5V relay when a password is entered correctly.
I’ll be using a 4X4 matrix membrane keypad in this article, but there’s also code and wiring diagrams for 3X4 matrix keypads as well. I like membrane style keypads because they’re thin and they also have adhesive backing so you can stick them to most flat surfaces. You can also get telephone style keypads that have thicker buttons if you like that style better. Even salvaged keypads from old telephones will work with the Arduino.