Arduino Alphanumeric keypad – Main task
Alphanumeric keypad Main project
Arduino alphanumeric keypad – Project requirements
- Arduino board (I am using Arduino UNO)
- 16×2 lcd.
- 4×3 keypad (You can also use 4×4)
- Potentiometer/Variable resistor
- Connecting wires
Alphanumeric keypad Arduino -Project circuit diagram
Some Tutorials related to the project
Arduino interfacing 16×2 lcd and 4×3 keypad alphanumeric keypad circuit diagram is given below.
Alphanumeric keypad with arduino, 16×2 lcd and 4×3 keypad – Project code
In the loop function i first set the lcd cursor on first row and first coulomb of lcd. Then alphkeypad() function is called. This function performs the function of alphanumeric keypad.
How does alphkeypad() function works?
The method is simple like we program our single character keypads. First make rows output and coulombs input. Now ground one row(rows are declared output) and keep other high. Press any button on the keypad and at microcontroller side check the status of the coulombs(coulombs are declared input) if any coulomb is found low(button pressed), do your stuff. If coulomb is found low(button pressed) do stuff like print some text or message on 16×2 lcd, run interrupt service routine etc. In our case we are printing character on 16×2 lcd.
Note: Rows and coulombs are interconnected and pressing a button will create a path between row and coulomb. So if row is declared output(high +5 v) and coulomb input(low 0 v). Then pressing and button on keypad will shorten row and coulomb, making high(+5 v) to appear on coulomb pin.
Internal structure of 4×3 keypad is shown in below picture.
Building Alphanumeric functionality
Now entering in the if statements. Coulomb-1 is checked first if its low then print ‘1‘ on 16×2 lcd and take a delay of 0.5 seconds
After 0.5 seconds another if statement in side the first statement checks that the same coulomb is again pressed or not. If pressed then print ‘a‘ on 16×2 lcd and go in to 0.5 second delay.
Again after 0.5 second check the same button if pressed(low) print ‘b‘ on 16×2 lcd and went in to 0.5 second delay.
Same step is repeated fourth time. All the if statements are part of the previous ones.
} Closing of fourth if statement
} Closing of third if statement
} Closing of second if statement
I hope you understand the above logic. Whole alphkeypad() function is placed in while loop. The control remains in the while loop until the while condition is not true, a is not equal to c.
- Button 1 printing 1-a-b-c
- Button 2 printing 2-d-e-f
- Button 3 printing 3-g-h-i
- Button 4 printing 4-j-k-l
- Button 5 printing 5-m-n-o
- Button 6 printing 6-p-q-r
- Button 7 printing 7-s-t-u
- Button 8 printing 8-v-w-x
- Button 9 printing 9-y-z
- Button 10 printing *-(-)-‘-‘
- Button 11 printing 0-&-|-!
- Button 12 printing #-%-^-&
Their is half a second delay in characters of a same button. For example button 1 is printing 1,a,b,c. Now if you want to print c. Press button 1 first time then with in half a second press it second time, then in half a second press it third time, then in next half a second press it fourth time and ‘c‘ will be displayed on the 16×2 lcd. If you do not press the button in half a second you will stuck to the last printed character and will be unable to go to next character. Take the example of mobile phone keypad. when you write message you press the first button, four times to print 1 on screen. If you don’t press the button in suitable time you will be unable to reach to 1. So you delete the last character and then go again for 1. Same concept applies here. If you don’t press the key in right time you will be unable to reach to your desired character.
I also made an alphanumeric keypad with 8051(89c51,89c52) microcontroller. If you wish to see that tutorial the link is below. Tutorial code is open source you can modify it according to your needs.