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 complete code with schematic is given here along with the hex file:

Download the Code with Schematic

Download HEX file

Thanks!

31 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