Arduino Nano 33 IoT - Keypad 3x4
This guide shows you how to use the Arduino Nano 33 IoT with a 3x4 keypad. In this lesson, you will learn:
- How to use a 3x4 keypad with Arduino Nano 33 IoT
- How to use a password entered on the keypad

Hardware Preparation
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of Keypad 3x4
A 3x4 keypad is a compact input device with 12 buttons arranged in a 3-row by 4-column grid. It typically includes numbers (0-9) and additional keys like * and #. Commonly used in embedded systems, security access panels, and microcontroller projects, it operates by detecting key presses through a matrix scanning technique.
3x4 Keypad Pinout
The 3x4 keypad has 7 pins in total, they are split into two groups: rows and columns:
- Four pins for the rows: R1, R2, R3, R4.
- Three pins for the columns: C1, C2, C3.

How Keypad Works
Check out how the keypad works here: https://arduinogetstarted.com/tutorials/arduino-keypad#content_about_keypad
Wiring Diagram between 3x4 Keypad and Arduino Nano 33 IoT

This image is created using Fritzing. Click to enlarge image
Arduino Nano 33 IoT - Keypad 3x4 Code
Detailed Instructions
If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:
- Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
- Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
- Launch the Arduino IDE on your computer.
- Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
- Click the Library Manager icon on the left side of the Arduino IDE.
- In the search box, type DIYables_Keypad and find the keypad library from DIYables.io.
- Click the Install button to add the keypad library.

- Copy the code above and paste it into the Arduino IDE.
- Click the Upload button on the Arduino IDE to build and send the code to your Arduino Nano 33 IoT board.
- Open the Serial Monitor in the Arduino IDE.

- Push some buttons on the keypad.
- Look at the result in the Serial Monitor.
Keypad and Password
A keypad is commonly used to verify someone's identity using a password. In this tutorial, a valid password is already set in the code. When a user enters the password on the keypad, it is checked against the pre-set password:
- If it matches, you are allowed access.
- If it doesn't match, you are not allowed access.
To use a password on the keypad, we choose two special keys.
- A key that begins entering the password. For example, the "*" key.
- A key that finishes entering the password. For example, the "#" key.
The password that a user enters will be saved in a text variable called the inputted password string. When a key is pressed:
- If the key you press is "*", remove everything you typed for the password to start over.
- If the key you press is not "*" or "#", add that key to the password you are typing.
- If the key you press is "#", compare the password you typed with the set password.
Keypad - Password Code
- Run the code shown above.
- Open the Serial Monitor in the Arduino IDE.

- Press the keys "123456" and then press the "#" key.
- Press the keys "7890" and then press the "#" key.
- Look at the result on the Serial Monitor. It should look like this: