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

 
Thanks!

70 comments:

  1. 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?

    ReplyDelete
  2. 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.

    ReplyDelete
  3. 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)?

    ReplyDelete
  4. 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.

    ReplyDelete
  5. 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.

    ReplyDelete
  6. 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

    ReplyDelete
  7. what is the output range of lcd?

    ReplyDelete
  8. 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?

    ReplyDelete
  9. 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'.

    ReplyDelete
  10. 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!

    ReplyDelete
  11. 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

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

    ReplyDelete
  13. 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

    ReplyDelete
  14. 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

    ReplyDelete
  15. 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...

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

    ReplyDelete
  17. 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

    ReplyDelete
  18. 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.

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

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

    ReplyDelete
  21. 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

    ReplyDelete
  22. 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!

    ReplyDelete
  23. 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

    ReplyDelete
  24. 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

    ReplyDelete
  25. 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

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

    ReplyDelete
  27. 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

    ReplyDelete
  28. 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

    ReplyDelete
  29. 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..

    ReplyDelete
  30. 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..

    ReplyDelete
  31. 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

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

    ReplyDelete
  33. 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

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

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

    ReplyDelete
  36. 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

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

    ReplyDelete
  38. 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

    ReplyDelete
  39. This comment has been removed by the author.

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

    ReplyDelete
  41. 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

    ReplyDelete
  42. 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

    ReplyDelete
  43. 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

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

    ReplyDelete
  45. hi sir ,

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

    ReplyDelete
  46. 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.

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

    ReplyDelete
  48. 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

    ReplyDelete
  49. 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

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

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

    ReplyDelete
  52. 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.

    ReplyDelete
  53. hello sir, I have been following your site since last few months, and all your posts were very much useful to me. I am working with AVR controllers for the past 2 months and your site does help me a lot. Thanks for sharing.

    ReplyDelete
  54. Very useful blog.Nice keep going!

    ReplyDelete
  55. Hi mr. Dharmani
    How can I write nubers on screen to some variable? Like I press 'A' then on screen word 'Hight' and then I type nubers. Thees number I need to write into int hight.

    ReplyDelete
  56. i want the above project with msp430f2413,pls help me

    ReplyDelete
  57. If you are looking for orange county solar companies at affordable or reasonable prices. Look no further, Burge Solar Power is one of the best solar panel company in California that specialises in installing the best solar panels at residential and commercial sites. For more information, you can call us at (951) 787-9800.

    ReplyDelete
  58. I conceive this web site is very instructive! I’m hoping to start my own blog soon but I’m a little lost on everything. 슬롯머신777사이트

    ReplyDelete
  59. That's why it's very hard to find, but I'm very fortunate to read your writing.
    바카라사이트

    ReplyDelete
  60. every recommendation of your website is awesome.

    ReplyDelete
  61. I actually think this amazing site needs a great deal more attention. Thanks for the advice! abogado de dui cerca de mí VA

    ReplyDelete
  62. Specializing in design with microcontrollers, he creates innovative and efficient tech solutions. His expertise spans various applications, ensuring optimized performance. Beyond technology, he advocates for wellness practices like hydra facial, promoting a balanced and healthy lifestyle.

    ReplyDelete
  63. Design with Microcontrollers" is an insightful resource that simplifies complex concepts, making microcontroller projects accessible for all skill levels. Its clear explanations and practical examples inspire creativity and innovation in electronics design immigration lawyer elizabeth nj

    ReplyDelete
  64. This project brilliantly demonstrates the versatility of the ATmega32 in interfacing a 4x4 matrix keyboard. The clear explanation of wiring and code implementation makes it easy to follow, inspiring creativity in further microcontroller applications. Great work showcasing embedded systems design.

    ReplyDelete
  65. In embedded systems, it's common practice to interface an ATmega32 microcontroller with a 4x4 matrix keypad in order to facilitate user input. misdemeanor prostitutionBy setting up the microcontroller's I/O ports, it is possible to scan the 16 keys that make up the 4x4 keypad, which are arranged in rows and columns. Usually, the rows are connected to four pins of a single port, while the columns are connected to four more pins.

    ReplyDelete