Keypad Control by Arduino Nano
Hello guys, Welcome back to my SriTu Hobby blog. Today we are going to talk about a topic that is very important to us. It’s about how to connect a keypad with an Arduino board. By that can get digital values to the Arduino board.
What is the keypad?
When we say a keypad, we mean something that contains letters, numbers, and characters. This is mainly seen in the security system and phones. There is a special keypad in the market that we can use with the Arduino. We can get them as 4 * 4, 4 * 3 etc. Today we will be using a 4*4 keypad.
This keypad has 16 keys. We can use 8 digital pins to access these 16 key inputs. These keypads are connected to the matrix way. Look at the photo below.
The rows and columns of these keypads are connected together. It uses 8 digital pins to control this. We can use this component to enter the passwords or phone numbers in the Arduino. Let’s talk about those topics in our next articles. We will first learn the Arduino basics.
Okay, let’s see how to use this keypad with Arduino Nano board. The required components are as follows.
- Arduino Nano board
- 4*4 keypad
Supplies
Firstly, identify these components.
Step 2
Connect this keypad to the Arduino board as shown below.
Step 3
Ok, let’s look at this code.
So, the first time we need the keypad library for working on this code. Use this link to download it. Then, insert it into your Arduino IDE. Follow the steps below.
OK, done. Now we must include the rows and columns pins we are using. For that, using two arrays. That’s are called ‘rows’ and ‘cols’.
After, we must create a char map using keypad characters. It uses a 2D array.
After that, we want an object for the keypad library. In this code, it is called “mykeypad”. It notifies the Arduino board about the pins and keys used.
The serial monitor is enabled to read key values.
Then create a char variable and take the keypad values.
Then, those values are checked using a condition and printed on a serial monitor.
Now, select the board and port. After, click the upload button.
Okay, it’s all over. Please press the keys to view the values on the serial monitor. You can then see the key value on the serial monitor.
The full video guide is below. Please watch it and try to use this knowledge in your own creations. So, we will meet in the next post.
Have a good day.