Introduction: Keypad With Arduino Without Using Keypad Library (First Tutorial)
Keypad used usually in most of projects to enable customer to deal with project such as (Real Time Clock (RTC) to adjust day,time ,access control,.....etc) but if you use it with keypad library of Arduino it's so easy and not good so here we will learn how to use it with Arduino without using keypad library in 3 Tutorials
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Components
all components we need are :
1- Arduino Uno Or Mega
2- 8 x Arduino Connection Wires (Male-Male)
3- 4x4 matrix keypad
Step 2: Calculation of Index of Any Element in 4x4 Matrix
if we look to the above picture we obtain that index of any element is equal to
index=Number of Row x4 +Number Of Column
Step 3: Connection
First Here Is The Pin configuration of keypad ....
R .... indicates the Row
C .... indicates the Column
Second Connect Keypad To Arduino As Following
Keypad Pin R1 –> Arduino Pin 2
Keypad Pin R2 –> Arduino Pin 3
Keypad Pin R3 –> Arduino Pin 4
Keypad Pin R4 –> Arduino Pin 5
Keypad Pin C1 –> Arduino Pin 6
Keypad Pin C2 –> Arduino Pin 7
Keypad Pin C3 –> Arduino Pin 8
Keypad Pin C4 –> Arduino Pin 9
Step 4: Upload the Code and Explaining
Here The code in the link below:
To illustrate the code i will explain it in few lines:
the following instructions are repeatedly executed every 50ms first it check if no button is pressed if that's true the no press flag will be set to ONE and counters h and v will be reset to ZERO then all outputs will be LOW then check all inputs if any one of them is LOW( h became the number of column) a for loop changes first output to HIGH if the input Which Was LOW is change to HIGH That's Mean that's is the correct row of ( v became the number of row) then make all output as low to disable an pressed until you released the pressed button Reset The no press flag to ZERO and calculate the index and return it while you hold any button the no press flag is ZERO and the function return 50 and switch case used to output on serial monitor according to the return form keypad function.