You are on page 1of 6

MIcrocontroller Projects (/)

Home (/)
8051 (/8051.html)
projects (/projects.html)
Lcd Interfacing (/lcdinterfacing.html)
PIC Microcontroller
Projects (/picmicrocontrollerprojects.html)
c++ projects (/cprojects.html)
Arduino (/arduino.html)
Xilinx (/xilinx.html)
Knowledge based
(/knowledgebased.html)
About Me (/aboutme.html)
Contact Me (/contactme.html)

Connect Ed
Circuit Diagram

Phone Number
Example Button

All About Electronics

The Project
Keypad

Web Designs

Job Requirements

(http://facebook.com)
(http://twitter.com)
(http://yahoo.com)
(http://www.linkedin.com
(https://plus.google

How to build an
Circuit board diagrams

How to interface 4x3 (Alphanumeric) keypad with Arduino


uno
Here is one more and complex project made using arduino. Project is about how to make and
interface an alphanumeric keypad with arduino uno or we shall call it how to program 4x3 keypad to
function like alphanumeric keypad. 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.

Programming method is same like we do programming of a simple 4x3 or 4x4 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
that can perform this task. If button is pressed 1 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.

In the project below I am going to interface 4x3 keypad and 16x2 lcd with arduino uno. 4x3 keypad is
programmed to perform alphanumeric keypad functionality. Characters and numbers associated
Keypad will be displayed on 16x2 lcd, if any button is pressed.

Project Requirements
Arduino uno (I am using Arduino UNO)
16x2 lcd.
4x3 keypad (You can also use 4x4)
Connecting wires
You can also use 4x4 keypad. Since 4x4 keypad contains 4x3 keypad in itself. If you use 4x4 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 4x4 keypad.
But to do that you first have to understand the code :-D
The method is simple, make rows output and coulombs input. Now ground one row and others should
be high. Press any button of the keypad then check the status of the coulombs if any coulomb is low
do your stuff. If coulomb is low do stuff like print some text or message on 16x2 lcd, run interrupt
service routine etc.
The above method is applied on simple 4x3 keypad. To design an alphanumeric keypad what we do
is checks the coulomb status. If it is grounded do some stuff and remain in the if-condition and check
the same button or coulomb second time if it is grounded do stuff and remain in second if-condition
and so on. If 4 alphabets are associated with your button then you should start from first and go until
4th condition is meet.

(/uploads/2/2/1/5/22159166/8013959_orig.jpg)
4x3(4x4) keypad programming for arduino to make it alphanumeric keypad

16x2 lcd is interfaced in 4-bit mode with arduino uno. RS(register select) pin of 16x2 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 16x2 lcd works? (/16x2-lcd-working.html)
USing 16x2 lcd in 4-bit mode with Arduino. (/how-to-use-lcd-in-4-bit-mode-with-arduino.html)
How to make Alphanumeric keypad with 8051 microcontroller? (/alphanumeric-keypad-with8051-microcontroller.html)
In the code i first imported the LiquidCrystal library. This library contains all the necessary functions to
initialize the 16x2 lcd. It also contains the functions to send commands and data to lcd. Then i defined
my rows and coulombs for keypad. Arduino pins 7 ,6 ,5 & 4 are dedicated for my keypad rows and
Arduino pins 3, 2 & 1 are dedicated for keypad coulombs. In setup function i initialized the lcd in 4-bit
mode and 5x7 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. The code is placed in
while loop. Program control will remain in this while loop until the a='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 16x2 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.

Project Code
#include< LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
const int r1=7;
const int r2=6;
const int r3=5;
const int r4=4;
const int c1=3;
const int c2=2;
const int c3=1;
void alphkeypad();
void setup()
{
lcd.begin(16 , 2);
lcd.clear();
pinMode(r1,OUTPUT);
pinMode(r2,OUTPUT);
pinMode(r3,OUTPUT);
pinMode(r4,OUTPUT);
pinMode(c1,INPUT);
pinMode(c2,INPUT);
pinMode(c3,INPUT);
}
void loop()
{
int i=0;
lcd.setCursor(0, 0);
alphkeypad();
}
void alphkeypad(){
char a='a';
while(a!='c'){
digitalWrite(c1,HIGH); digitalWrite(c2,HIGH);digitalWrite(c3,HIGH);
digitalWrite(r1,LOW);digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);digitalWrite(r4,HIGH);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('1');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear(); lcd.print('a');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear(); lcd.print('b');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear(); lcd.print('c');delay(500);}}}
a='c';
}
digitalWrite(r1,LOW);digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);digitalWrite(r4,HIGH);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('2');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('d');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('e');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('f');delay(500);}}}
a='c';
}
digitalWrite(r1,LOW);digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);digitalWrite(r4,HIGH);

if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('3');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('g');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('g');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('i');delay(500);}}}
a='c';

digitalWrite(r1,HIGH);digitalWrite(r2,LOW);
digitalWrite(r3,HIGH);digitalWrite(r4,HIGH);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('4');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('j');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('k');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('l');delay(500);}}}
a='c';

digitalWrite(r1,HIGH);digitalWrite(r2,LOW);
digitalWrite(r3,HIGH);digitalWrite(r4,HIGH);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('5');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('m');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('n');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('o');delay(500);}}}
a='c';

digitalWrite(r1,HIGH);digitalWrite(r2,LOW);
digitalWrite(r3,HIGH);digitalWrite(r4,HIGH);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('6');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('p');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('q');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('r');delay(500);}}}
a='c';
}
digitalWrite(r1,HIGH);digitalWrite(r2,HIGH);
digitalWrite(r3,LOW);digitalWrite(r4,HIGH);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('7');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('s');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('t');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('u');delay(500);}}}
a='c'
;
}
digitalWrite(r1,HIGH);digitalWrite(r2,HIGH);
digitalWrite(r3,LOW);digitalWrite(r4,HIGH);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('8');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('v');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('w');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('x');delay(500);}}}
a='c';
}

Facebook Account
Login
World's Largest Online
Community. Join for
Free & Enjoy the
Benefits!

digitalWrite(r1,HIGH);digitalWrite(r2,HIGH);
digitalWrite(r3,LOW);digitalWrite(r4,HIGH);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('9');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('y');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('z');delay(500);
}}
a='c';
}

Facebook Account
Login
World's Largest Online
Community. Join for
Free & Enjoy the
Benefits!

Facebook.com

Create a Facebook
Profile
Get Free Email, Chat, &
Messaging. Join for Free
& Enjoy the Benefits!
Facebook.com

Create a Facebook
Account
World's Largest Online
Community. Create a
Facebook Profile for
Free!
Facebook.com

Facebook.com

digitalWrite(r1,HIGH);digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);digitalWrite(r4,LOW);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('*');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('(');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print(')');delay(500);
if(digitalRead(c1)==LOW){
lcd.clear();lcd.print('-');delay(500);}}}
a='c';
}

Create a Facebook
Profile
Get Free Email, Chat, &
Messaging. Join for Free
& Enjoy the Benefits!
Facebook.com

Create a Facebook
Account
World's Largest Online
Community. Create a
Facebook Profile for
Free!

digitalWrite(r1,HIGH);digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);digitalWrite(r4,LOW);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('0');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('&');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('|');delay(500);
if(digitalRead(c2)==LOW){
lcd.clear();lcd.print('!');delay(500);}}}
a='c';
}

Facebook.com

digitalWrite(r1,HIGH);digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);digitalWrite(r4,LOW);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('#');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('%');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('^');delay(500);
if(digitalRead(c3)==LOW){
lcd.clear();lcd.print('&');delay(500);}}}
a='c';
}
}//WHILE ENDING
}//KEYPAD

ENDING

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.
Connect Ed
Circuit Diagram

Phone Number
Example Button

The Project
Keypad

Web Designs

Job Requirements

How to build an
Circuit board diagrams

OSD Displays
osddisplays.com

Standard and Custom TFT-LCD, OLED, STN & TN LCD modules

Alphanumeric-Keypad with Arduino


(/uploads/2/2/1/5/22159166/alphanumeric_keypad_with_arduino.rar)

16X2 LCD Display


Arduino LCD Keypad Shield
Alphanumeric LCD Module

Cakra Kusuma Hotel


Yogyakarta
as low as

IDR704,100

book now!

comments powered by Disqus (http://disqus.com)

8051 projects (/projects.html)


C++ projects (/c-projects.html)

Arduino projects (/projects.html)


based (/knowledge-based.html)

Xilinx (/xilinx.html)

About me (/about-me.html)

Knowledge

Copyright 2014 microcontroller-project.com. All rights reserved.


Unless otherwise indicated, all materials on these pages are copyrighted by the microcontroller-project.com. All rights reserved. No
part of these pages, either text or image may be used for any purpose other than personal use.

You might also like