=============================================================================================================

Sunday, November 30, 2008

4x4 Matrix Key-board Interfacing with ATmega32


Hi guys,
Here is a project for beginners to interface a 16-key (4x4) keypad with ATmega32 using 8-pins i.e. one port of the microcontroller. This is useful particularly where we need more keys but don't want to spend more uC pins for interfacing.
The 4x4 keypad is a standard one available in the market. I've used here one from my earlier project. The LED shown in the schematic is just extra, which can be used anyway you like.
Here, the mega32 reads the code of key pressed and sends relevant character to display on LCD 2nd line. The first line displays 'WELCOME' all the time.

The figure below shows ISIS Proteus Simulation of this code:


Download
------------------
Source Code (AVR-GCC, winAVR, AVRStudio format)
Proteus Simulation model
Source Code (CodeVision AVR format)
Source Code with 4-bit LCD Implementation (ICCAVR)
Source Code (ICCAVR) with Schematic on Google Docs
HEX file


Thanks!

54 comments:

Rahul said...

I have tried to run the exact code on atmega 16 after making the header file alterations..but it doesn't work...can u help?

CC Dharmani said...

Hi Rahul,

which compiler r u using? Can u send me your code on ccd@dharmanitech.com, I'll just have a look and send you back with corrections, if any required.

Regards.

Anonymous said...

i already compile it with avr studio(gcc-compiler).i choose avr 32 simulator but when i try to run it, there are lot of errors.
are you sure this code has no error when you compile it because when i run it,the errors show that PORT A,PORT B,PORT C,PORT D,MCUCR and TIMSK are undeclared.

and can i try your code on avr butterfly (ATmega 169)?

CC Dharmani said...

Hi, the errors are due to the compiler change. I've written the code in ICCAVR, but you are compiling it with AVRStudio.
You have to change the header files and certain other lines in the code to match AVRStudio (winAVR) compiler.
Try it out, if it doesn't work write to me, I'll send you the converted file for AVRStudio.

Anonymous said...

i already try it but i still got an error.can you send me the converted code so i can compile it with AVRStudio..

1 more question
can i modified your circuit?
what i mean is can i using another microcontroller?.i want to use AVR Butterfly(ATmega 169) instead of ATmega 32 that you using now.

rishabh said...

sir,i'm trying to drive a 16 segment alphanumeric display with 4*4 keypad and 89s52 muci.
can you please explain the connections of keyboard with 8952.
moreover can the programming be done in such a way to have all 27 alphabets and 10 numbers using two digit input in the 4*4 matrix keyboard. that would be of gr8 help.thanks
pls rep me at- alwaysrish@gmail.com

amir said...

what is the output range of lcd?

CC Dharmani said...

Hi I didn't get it! The input voltage level of the LCD is normally 5v. The number of characters depend on size, can be 8x1, 16x1, 16x2, 20x2 etc..

What exactly is the question?

rishabh said...

really srry !!!
i'm basically trying to rig up some led's in form of a 16 segment display...and interfacing it using 4*4 keypad with 89s52.4*4 keypad can accomodate only hexa characters till 'f'.i want to program it till 'z'.

CC Dharmani said...

Hi rishabh,
you can have each key with multiple characters, just like the way it's done in cellphones. Pressing the same key again would display next character. You can assign each key with 4 characters, as per the key order in cellphone keypads. There you can display all the alphabets, numbers plus some extra characters!

abhijit said...

Hi.
I have ru your code on 8-bit LCD , and there it is working fine, but I want the same code to work on 4-bit LCD..
if u have that code , can u please give it to me..............

Regards
Abhijit Kumar

CC Dharmani said...

Hi Abhijit, I've sent you the code modified for 4-bit LCD data. Test it out.

Anonymous said...

Would you please write me this program in codevision syntax?

I've posted a thread here :
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=574229#574229
I hope you can help me...

Thanks in advance...

regards
kuntawinangun

CC Dharmani said...

Hi kuntawinangun,
converting the code into CodeVision format needs very little changes. I can send it to you, drop your mail id here or mail me on ccd@dharmanitech.com

Anonymous said...

this is my email address :
kuntawinangun@yahoo.com

thanks a bunch man, i'm really appreaciate it...

I'll learn a lot, as I promised...

once again, thank you...

CC Dharmani said...

Hi,
I've sent you the code in CodeVision AVR format on your mail id. Check it out.

shanmu said...

Hi
All your posts were very much useful to me. I am working with AVR controllers for the past 2 months. I have successfully completed the 8bit LCDHD44870 display, But I am not getting the result with 4bit mode. Can you provide me some example codes, and some explanation regarding the same. I am working with AVR studio 4. Looking out for your help

Thanks and regards
shanmu

CC Dharmani said...

Hi Shanmu, put up your mail id in the comments or mail me at ccd@dharmanitech.com, I'll send you the 4-bit LCD functions, you can directly use them.

Anonymous said...

I have sent you an e-mail for the avrstudio code version :D. thank you ;)

CC Dharmani said...

Ya, I've sent you the converted code, in AVRStudio format. Enjoy!:)

TalkNollyWorld said...

Hi, how can you help me. I need to design a circuit that will make use of a 4 by 4 matrix keypad, and LCD & a 8051 microcontroller. The result should be that whatever number(1-0) i press on the keypad should be displayed on the LCD. Thanks
PAUL

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

Anonymous said...

sir


i am trying AVR programming in three months,i need asm code for
4x4 key pad i am using AVR Studio 4.16 please help me

advance thanks!..

my mail id

Regards
R.Karthikeyan

Anonymous said...

sir


i am trying AVR programming in three months,i need asm code for
4x4 key pad i am using AVR Studio 4.16 please help me

advance thanks!..

my mail id

mrk_srp@yahoo.co.in

Regards
R.Karthikeyan

Yoel Manuel said...

Hi I see so interensting your forum ,I have started working with AVR16 2 months ago.Can you send the code for AVRStudio and CodeVisioan, 4 bits Lcd to yoel22pe@gmail.com

ashok said...

hi mr.darmani .. how to interface the pwm control of dc motor set with the system? can you send the code for it?

Guru Karki said...

Hi.
I have ru your code on 8-bit LCD , and there it is working fine, but I want the same code to work on 4-bit LCD..
if u have that code , can u please give it to me..............

my email kguru@cedt.iisc.ernet.in


Thanks and Regards

ravindra said...

hello dharmani

i complied the code in avr studio i am getting many errors.

can u send me the correct code for avr studio

my mail id is: ravindra.pesse@gmail.com

Anonymous said...

Hi m rakesh.m doing project of electronic restaurnt menu,i tried for the code but all in vein,so will u plzzzzz give me the code & hex files,,,,circuit diagram i got but its nt working,so will u plzzzzzzz help me out..

Anonymous said...

Hi m rakesh.m doing project of electronic restaurnt menu,i tried for the code but all in vein,so will u plzzzzz give me the code & hex files,,,,circuit diagram i got but its nt working,so will u plzzzzzzz help me out..

swati said...

i had run the code on code::bloks 8.02.the program bulid properly but it can not initialise lcd and did not show the proper o/p of keypad

Anonymous said...

Can u jus post the code for atmega16 in avrstudio... i am trying to modify the code... but its not helping...

PLC said...

i already compile it with avr studio.i choose avr 32 simulator but when i try to run it, there are lot of errors.
when i run it,the errors show that PORT A,PORT B,PORT C,PORT D,MCUCR and TIMSK are undeclared.

Please, sir send to me the correct .h files and how to include it because i am not good to work with AVRstudio because i am working with Micro c.

My mail EngineerAN@gmail.com

dd said...

Hello.
Could you please provide me the code for avr studio?
Many thanks

Anonymous said...

For microcontroller projects http://worldofmicrocontroller.blogspot.com/

Anonymous said...

Hello Dharmani,

I have tried to build simple temperature controller with AVR, this is my project, but failed. The AVR based controller with keypad and LCD display, I'll give a teperature limit, lower and higher through keypad. A sensor (LM35) connected to port measures temp and controller compare with the range and will give me warning..those are whole bunch of task my comtroller will do..pls help me with schematic and code in C.
Thanks for now.

Regards.

nazmul

Anonymous said...

Hi,I am trying to interface 4x4 Matrix keypad and LCD with Arduino. Can you help me with the schematics and code?

Anonymous said...

Sir i want to drive an lcd which supports all the alphabets using 3 cross 4 keypad with an 8051 microcntroller . if u can help me with the coding it ll b a grt help. my email id is asad786kamal@rediffmail.com

from ASAD KAMAL

Sagar Sojitra said...
This comment has been removed by the author.
nirnayam said...

hi i m looking for avr-gcc keyboard interface program for 16x2 lcd display can u help...?

Naina said...

Hi,

The above code of keypad works fine,but if i want to use different port pins of different ports ,say for rows 2,3,4,5 of Port A & columns 2,3,4,5 of Port B what changes are needed in the code

indra said...

If yo like to use the ATMEGA8535 and bascom AVR you can check out at [URL="http://bagindra.blogspot.com/2012/03/digital-combination-key-using-key.html"]Digital combination key using keypad 4x4[/URL]. even though its not the same board and controller you should be able to get the fair idea about what you need to do

indra said...

If yo like to use the ATMEGA8535 and bascom AVR you can check out at Digital combination key using keypad http://bagindra.blogspot.com/2012/03/digital-combination-key-using-key.html. even though its not the same board and controller you should be able to get the fair idea about what you need to

do

Muhammad Rvhani said...

Thanks....
I need more a night for learning this code.
Thanks..............

rohith ks said...

hi sir ,

I want to interface TCD1304 to ATMEGA32 can u send me the codes for this .pls help me to implement it

Praveen B said...

I AM CONNECTING ROWS TO ONE PORT AND COLUMNS TO ANOTHER PORT, HOW TO SCAN THE KEYPAD WHEN THE KEY IS PRESSED CAN U POST THE CODE PLZ.

mai diab said...

thanks alot :)

Ahsan Jalal said...

plz send me the code that works on avr studio 5 .i am using atmega32
email
ahsan856jalal@gmail.com

Deepak.K Kriahnan said...

can any one help me..i need util/delay.h and avr_io.h files..i ve avr7.2 demo version these two file not there ..if any one have it..pls send me link r post file...its urgent

sixtus molete nts'oebe said...

Hi,can you please provide me with the code that will enable me to enter one letter or one number at the time using PIC16F887.pls send it on sixtusmolete@gmail.com

Soubhik Chatterjee said...

hi ,
what is J1 in power supply circuit...And could you explain the 12 V input, J1, black rectangle there,1,2,3 there.....

Harold said...

nice post! Thank you

M. Catur Ardyatno - said...

i try the 4 bit code from your blog, but it doesn't work. can't you help me?
thanks sir

Sumair Shahid said...

hi mr. dharmani...
brother can you please send me the code (8bit lcd+ 4x4 keypad interfacing with at mega 16.)
these files are no longer available in the download link given.