Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

How to interface 4×3 (Alphanumeric) keypad with Arduino uno : Arduino Alphanumeric keypad programming

By EG Projects

Here is one more and complex project made using arduino uno. Project is about how to make and interface an alphanumeric keypad with arduino uno or we shall call it how to program 4×3 keypad to function like alphanumeric keypad with arduino uno. The project is complex in the scenario that its code is complex and it requires very sharp brain to understand the logic present in the code. One who wants to understand the code must not be a newbie in Arduino programming. I will try to explain the alphanumeric logic as easily as i could.

Arduino Alphanumeric keypad – Main task

Alphanumeric keypad programming method is same like we do programming of a simple 4×3 or 4×4 keypad. The extra stuff in the code is now one button is carrying 3 to 4 numbers and characters and we have to write logic which can perform this task. If button is pressed first time print the first character, if the same button is pressed second time with in a suitable time print the second character and so on to number of characters present on a single button .

Alphanumeric keypad Main project

In the project below I am going to interface 4×3 keypad and 16×2 lcd with arduino uno. 4×3 keypad is programmed to perform alphanumeric keypad functionality. Characters and numbers associated with each button on keypad will be displayed on 16×2 lcd if any button is pressed. 4×3 keypad has 4 rows and 3 coulombs. Characters and numbers associated with each button are shown below in picture. You can purchase any 4×3 keypad from market and interface it with arduino uno. The keys will perform same function given below because keypad it self is nothing all the functionality is controller by microcontroller through code. Keypad will perform function what it is mapped in the code. I mapped the keys shown below. 
arduino uno alphanumeric keypad

arduino uno alphanumeric keypad

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
You can also use 4×4 keypad. Since 4×4 keypad contains 4×3 keypad in itself. If you use 4×4 keypad then the fourth coulomb of keypad will be kept void, do not connect it with arduino. If you press any key of fourth coulomb, nothing will happen. You can also modify the code and make it for 4×4 keypad. But to do that you first have to understand the code 😀
4x3(4x4) keypad programming for arduino to make it alphanumeric keypad- Circuit Diagram

4×3(4×4) keypad programming for arduino to make it alphanumeric keypad

Alphanumeric keypad Arduino -Project circuit diagram

16×2 lcd is interfaced in 4-bit mode with arduino uno. RS(register select) pin of 16×2 lcd is connected to Pin#13 of Arduino. E(enable) pin of lcd is connected to Pin#12 of Arduino. D4, D5, D6 & D7 data pins of lcd are connected to pin 11, 10, 9 & 8 of Arduino. Usually all the eight data pins of lcd are used in the projects. But when we want to save the pins of our microcontroller we use lcd in 4-bit mode. In this mode 8-bit character is divided in to two nibbles (1 nibble=4-bit) and data is send in nibbles. 

Some Tutorials related to the project

  • How does 16×2 lcd works?
  • Using 16×2 lcd in 4-bit mode with Arduino.​


Arduino interfacing 16×2 lcd and 4×3 keypad alphanumeric keypad circuit diagram is given below.
 

Alphanumeric keypad with arduino uno 16x2 lcd and 4x3 keypad

Alphanumeric keypad with arduino uno 16×2 lcd and 4×3 keypad

Alphanumeric keypad with arduino, 16×2 lcd and 4×3 keypad – Project code

In the code i first imported the LiquidCrystal library. This library contains all the necessary functions to initialize the 16×2 lcd and display characters on lcd screen. It also contains the functions to send commands and data to 16×2 lcd. Then i defined my rows and coulombs for keypad. Arduino digital pins 7 ,6 ,5 & 4 are dedicated for my keypad rows and arduino uno digital pins 3, 2 & 1 are dedicated for keypad coulombs. In setup function i initialized the lcd in 4-bit mode and 5×7 character display, made rows output and coulombs input. 

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.

4x3 keypad rows and coulombs interaction

4×3 keypad rows and coulombs interaction

Building Alphanumeric functionality

The above method is applied on simple 4×3 keypad. To design an alphanumeric keypad what we do is check the button status multiple times in a given amount of time out period. If button is grounded do some stuff and wait for some time. Then again check the same button second time if it is grounded do stuff  and wait for some time. Repeat the same process for number of characters present on the button. Explaining through code will be little easier.
digitalWrite(r1,LOW);digitalWrite(r2,HIGH);         Row-1 is made low and all the others are high.
digitalWrite(r3,HIGH);digitalWrite(r4,HIGH);

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      
if(digitalRead(c1)==LOW){
    lcd.clear();lcd.print(‘1’);delay(500);
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.
if(digitalRead(c1)==LOW){
     lcd.clear(); lcd.print(‘a’);delay(500);
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.

if(digitalRead(c1)==LOW){
      lcd.clear(); lcd.print(‘b’);delay(500);

Same step is repeated fourth time. All the if statements are part of the previous ones.
if(digitalRead(c1)==LOW){
       lcd.clear();  lcd.print(‘c’);delay(500);
} Closing of fourth if statement
} 
Closing of third if statement
} Closing of second if statement
} 
Closing of first 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. 

Keypad buttons with associated numbers and characters.

  • 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.  

In the above tutorial i am printing a single character at a time on 16×2 lcd. New character on lcd removes the first one. If you want to write a text message using alphanumeric keypad then some other 16×2 lcd commands are need to be utilized. If you want to write a full string text or want other characters to be a part of 4×3 alphanumeric keypad then write me your needs.    

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.  

8051 alphanumeric keypad project

Download the project files. Folder contains the project code and arduino .ino file. Give us your feed back on the post. If you feel any difficulty in the code leave your message below.

Alphanumeric-Keypad with Arduino


Filed Under: Arduino, Microcontroller Projects

 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What is a loop calibrator? 
  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • 7 segment display connections
  • Passive Harmonics Filter
  • file edit
  • RCF Subwoofer Amplifier PIC16F870-I/SP please help me about hex code
  • Active Balun Design

RSS Electro-Tech-Online.com Discussions

  • Control Bare LCD With ATmega328p
  • Need a ducted soldering fan for solder smoke extraction
  • Identify a circuit.
  • Sla ir li ion
  • Question about ultrasonic mist maker
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering