How to use a LCD with your electronic devices?

February 14th, 2006

LCD Title, ATMEL AVR ATMega16 and LCD Seiko L2022, HD44780
Almost a month has passed since I have created the Function Generator; sorry for that, it is not my fault. I had final exams so I had to learn. Finally I have holidays, so something should be going on the site. However, let’s get to the project. Today you can rarely see an electronic device without a LCD display, even new fridges have it. It is pretty useful to know how to use some with your device. I will show you how to connect a LCD with a Microcontroller. :-)

When you see all these weird code names please don’t get scared, they are just names like John, Michael and etc…

Most of the characters LCDs run on a HD44780 controller so I used one from Seiko, the Seiko L2022. You can get this one or other LCDs from ShopEIO. You can get such LCDs for less than 5$. To control this LCD I preprogrammed an ATMEL AVR ATMega 16 microcontroller (MCU).

I had to use my Weller solder iron, my STK500 ATMEL AVR programmer and a loupe.

Weller solder iron
My solder iron, it is quite old but Weller makes a first class solder irons.

In case you have never done some soldering I have found a great tutorial for you with an enormous number of photos to see how it is done Link. In case you ask yourself “Why the heck do you need a loupe,” it is nice to check your joints after soldering them, this way you avoid mistakes and the process of resoldering and desoldering again.

STK500 ATMEL AVR Development Board
Here you can see the STK500 (the AVR programmer) and the loupe.

If you don’t have a STK500 you can use any other ATMEL AVR programmer or even build one yourself Link or Link. However, I recommend to buy one because it is simpler than building it yourself and they don’t cost that much, in case you want to spend more money on a high quality programmer then get yourself the STK500. It is easy to use and a fun to play with.

Scheme ATMEL AVR ATMega16 HD44780
LCD Scheme, connecting AVR with the LCD (click on the scheme to enlarge it)

  1. /*
  2. LCD Demo
  3. CodeVisionAVR C Compiler
  4. (C) 2000-2002 HP InfoTech S.R.L.
  5. www.hpinfotech.ro
  6. */
  7.  
  8. #include "mega16.h"
  9. // the LCD is connected to PORTC outputs
  10. // see the file lcd.h in the ..inc directory
  11. // 0×15 is the address of PORTC
  12. #asm
  13. .equ __lcd_port=0×15 ;PORTC
  14. #endasm
  15.  
  16. // include the LCD driver routines
  17. #include "lcd.h"
  18.  
  19. void main(void)
  20. {
  21.  
  22. // initialize the LCD for
  23. // 2 lines & 16 columns
  24. lcd_init(20);
  25.  
  26. // go to the firs line of the LCD (x,y)
  27. lcd_gotoxy(0,0);
  28.  
  29. // display the message
  30. lcd_putsf(“http://www.e-dsp.com”);
  31.  
  32. // go to the second line of the LCD (x,y)
  33. lcd_gotoxy(0,1);
  34.  
  35. // display the message
  36. lcd_putsf(“Hello World! :-));
  37.  
  38. // stop here, loop now
  39. while (1);
  40.  
  41. }

ATMEL AVR ATMega16 and LCD Seiko L2022, HD44780 working
The result of our work we can see here! Enjoying, right??

That would be it, ain’t it easy??? In case you need more help or more details let me know. I will help you in the forum or just leave a comment. Thank you for reading this :-) !

Entry Filed under: Electronics, DIY

72 Comments Add your own

  • 1. b  |  |  February 20th, 2006 at 8:23 pm

    this looks great :)
    but where do you get the LCD routines :)
    are they part of the CodeVision AVR C Compiler?

    do you know the Arduino project?
    www.arduino.cc it’s all open source, from the board to the code for now it uses the Atmega8 but it is thought to be expandable to also other processors.

    anyhow, keep up the good work
    thanks for your tutorials and code
    b.

  • 2. refikh  |  |  February 21st, 2006 at 12:37 pm

    The LCD routines are part of the CodeVision C libraries. I think I have seen this project somewhere on the web and it looks cool, all kind of expanding the community contributes everybody here. Thank you b for the comments.

  • 3. farzad  |  |  March 27th, 2006 at 8:01 pm

    thanks

  • 4. Jim  |  |  April 1st, 2006 at 2:34 pm

    Very Nice site.
    Thanks for the code. If we use ADC of the ATmega16 and we want to see the result of the conversion in the LCD Display what we have to do ?

    for example : ADC = ‘RESULT OF CONVERSION’
    I am asking because the result is not a string. How can we do something like this ??

    Thanks a lot

  • 5. Jeff Bader  |  |  April 10th, 2006 at 7:43 pm

    I have the Epson EA-D16015AR lcd and can not get the thing to work. (16 x 1) Can anyone help me? My email is jebader@georgefox.edu. Thank you!

    Jeff

  • 6. Jeff  |  |  April 12th, 2006 at 8:05 am

    I have tried the built in Code Vision lcd functions, and I can’t get it to work. I need help!

    Thank you.

  • 7. Cisse  |  |  April 30th, 2006 at 12:21 am

    Hi,
    I would like to redo what you exactly did.
    I have no electronics experience or background. But I have some programming experience and willing to learn.
    Thank you for the links.

    Would you tell me what tools I will need?
    This is what I am thinking:
    - A software to wrtie the code “Hello World’
    - A book on programming for that software.
    -All other electronics tools I will need to put together to get this result.
    Thanks again.
    Please reply to my email (mohcis@yahoo.com) in case I forget to come back on the site.
    Cisse.

  • 8. Alex Lee  |  |  May 5th, 2006 at 12:45 am

    i got my LCD working, the LCD can be bought from www.farnell.com 2×16 from sunplus (Part Number: MC1602D-SYR) which this LCD costs around £8.00

  • 9. ICAN  |  |  May 9th, 2006 at 4:08 pm

    I make that circuit. but it doesn’t works. Which version of Codevision AVR do you use? I can’t see anything on lcd

  • 10. lupe  |  |  May 11th, 2006 at 5:40 am

    can you help me with my lcd display 4 x 20 it is working but having problems with cursor movement. I am using BASCOM.

  • 11. winston  |  |  June 13th, 2006 at 2:22 pm

    I have used codevision en I test DS1820 but dosn’t work !
    Could you help me?
    I appreciated any help

  • 12. Parisa  |  |  July 1st, 2006 at 5:44 pm

    Hi
    I need the shematic of connecting LCD 2*16 to ATMega8.
    I work with codvision and need a funcyion to work with each of charecters sepratly.

  • 13. Sara  |  |  July 8th, 2006 at 7:54 am

    I am trying to program a Mega128 so that is displays information on a 2 by 16 alphanumeric LCD but it does not seem to be working. Am I suppose to use lcdstk.h or lcd.h, I am using stk300 to program. My email is sarawatch@yahoo.com

    Thanks

  • 14. Parisa  |  |  July 10th, 2006 at 12:30 pm

    Hi
    I want to work with A\D of micro ATMega 8 and need it’s code on Codevision.

  • 15. hadi  |  |  July 24th, 2006 at 6:48 am

    Hi
    I have a project with atmega16+lcd16*1+at24cxx
    with avr studio+shematic
    I have a project with atmega16 +graphiclcd 128*64
    +at24cxx with avr studio+shematic

  • 16. shreyans  |  |  July 27th, 2006 at 11:49 am

    hi
    i want to learn using a lcd…
    i have very less knowledge or background in electronics…
    plz help how to get started…
    i have some knowledge abt the microcontroller AT89S51…

  • 17. zack  |  |  July 30th, 2006 at 2:37 pm

    If we use ADC of the ATmega16 and we want to see the result of the conversion in the LCD Display what we have to do ?

    how to display value of mathematics because it’s not string?
    thanks

  • 18. Niraj Dave  |  |  August 1st, 2006 at 11:16 am

    i have “CASIL” CCM1620CSL 16X2 LCD but how can i run this lcd by using atmega16 ?

  • 19. behbood  |  |  August 2nd, 2006 at 6:35 am

    hi.
    i’m working by ATMEGA16, ATMEGA32
    and i need some shematic & code with CODVISION
    thenks

  • 20. navid alaei shayne  |  |  August 12th, 2006 at 11:23 am

    thanks dear. can i have another examples.

  • 21. Kevin Taka Ouma  |  |  August 20th, 2006 at 10:24 am

    Hi.

    Good job you are doing. Very good.

    I’m a college student studying an alectronics course, and would really appreciate your help.

    I’m working on my course project where i have to design an audio voltage display.

    Instead of using LEDs for my light display (since everybody else is using them), I wanted to use LCDs. I waned to be a bit different.

    I don’t know much about codes and stuff, but I’m trying to understand what you have posted. However, I would be really grateful if you would show me how to simply light an LCD of any Nokia phone, so long as it’s a bright LCD. All I’d like to do is light an LCD without it being connected to the phone. Just light it independently.

    Kindly assist me if you can.

    Thanks a lot.

  • 22. maryam  |  |  August 28th, 2006 at 11:00 am

    hi nice site
    i’m working by atmega16.
    i need a shematic of connecting LCD 4*20 to atmega16

  • 23. amir  |  |  August 29th, 2006 at 5:30 pm

    Hi nice site
    I’m working by atmega16/codevision

    I need header files for grafic & character lcd

  • 24. Prashant  |  |  September 1st, 2006 at 11:27 am

    I am a BE student and we are doing our final project.
    We needed help for interfacing Lcd to our Atmel chip.We are using AVR for the same.Will u guide us with this interfacing.

  • 25. mahmood  |  |  September 12th, 2006 at 9:56 pm

    lcd graphic nokia avr codevision code for drive

  • 26. zahra  |  |  September 16th, 2006 at 12:56 am

    hi dears:
    how can i use and sho a image on a grafic lcd?
    thanks alot.

  • 27. mihir  |  |  September 24th, 2006 at 3:58 pm

    I have the same problem as Zahra : how do I show a moving image on a color LCD? I want to use a PIC controller to do this..how do I select one??can you help me? thanks a lot

  • 28. hosein  |  |  October 6th, 2006 at 12:29 pm

    HI REFIK
    i have a grafic lcd but i don’t know how can i show an image on it.
    (it’s better for me to use a pic mcu).is there any software to do that?
    thanks

    BEST REGARDS.
    HOSEIN

  • 29. zohreh  |  |  October 6th, 2006 at 3:26 pm

    the ssite was good

  • 30. zohreh  |  |  October 6th, 2006 at 3:29 pm

    this very good

  • 31. HOSEIN  |  |  October 9th, 2006 at 11:05 am

    HI DEAR REFIK
    as you said i searched on google and i found a software to show image on grafic lcd,thank you
    now i have a new question:
    how can i transfer data between micro and a sd/mmc memory?

  • 32. Naveen  |  |  October 18th, 2006 at 5:54 am

    Hi,
    This is a nice site with good tutorial.I want to interface HD44780 to MSP430 microcontroller. Can you suggest me how to start with it.

    Thanks

  • 33. topsy  |  |  October 19th, 2006 at 6:09 pm

    please send the Header file for the CCM1620CSL model, since i dont have the programmer for the CCM1620CSL model.

  • 34. Mahdi  |  |  October 26th, 2006 at 11:25 pm

    HI freinds

    I am intrested to drive Graphical Lcd with AVR micros.
    can anybody suggest me how to start with it.

    Bests.

  • 35. ROSTAM  |  |  November 13th, 2006 at 8:42 am

    HI
    can you help me with my graphic lcd display 64 x128 . how to initialize it and how to write something to its momory.

  • 36. ahmed  |  |  November 13th, 2006 at 9:33 pm

    i want to use lcd with keyboard in my digital project

  • 37. Mohsen  |  |  November 21st, 2006 at 1:48 pm

    Dear sir ;
    I use this program (or even easier than it)in code vision but no signal where found on port c (i use c port) . Next I put a bufferbetwin micro(atmeg16) and LCD but same as I said it has not work (or even a signal on port c) please help me (what would make this happen) best regards M_H

  • 38. wathik  |  |  November 23rd, 2006 at 9:40 am

    I tried in Code Vision lcd functions & PROTEUS professional and I can’t get it to work. I need help!

  • 39. jalal  |  |  November 23rd, 2006 at 12:04 pm

    HI
    can you help me with my graphic lcd display 64 x128 . how to initialize it and how to write something to its momory.

  • 40. saghae  |  |  November 27th, 2006 at 9:33 am

    Hi!
    I wrote lcd program in CodeVision with ATmega32 ,2 * 16 lcd but dont work.it’s hardware is safe and good .Please help me!

  • 41. DomX  |  |  November 30th, 2006 at 3:03 am

    to saghae:
    If you use LCD with hitachi driver, you have to connect pins right:

    (Described in CodeVision Help)

    [LCD] [AVR Port]
    RS (pin4) —— bit 0
    RD (pin 5) —— bit 1
    EN (pin 6) —— bit 2
    DB4 (pin 11) — bit 4
    DB5 (pin 12) — bit 5
    DB6 (pin 13) — bit 6
    DB7 (pin 14) — bit 7

    A (pin (underlight)—– + ??V (like diode, cca 0,6V???)
    K —- GND
    pin 1,2,3,7,8,9,10 - GND

  • 42. Torsten  |  |  December 14th, 2006 at 3:34 pm

    Hallo,
    I am from germany.
    I need the Pinning how to connect the LCD, shown in the first and last picture.
    Typ: SII L2022 Rev.B with HD44780 and connector 1..16

    I know only, that PIN 15+16 is the underlight ??? Volts, I think 5V ?

  • 43. saber motasadi  |  |  December 25th, 2006 at 9:51 am

    hi tnx for this site i need you help i need the source lcd graphic model t6963
    and program by assember or c can you send me this source?

  • 44. ervin  |  |  December 30th, 2006 at 8:27 pm

    hi
    i have connected phone keypad and lcd to the avr atmega16 and want to show numbers on lcd each time l press a key .but my lcd doesnt show any thing what’s the problem ?
    i want its program in codevision and i also work with the proteus similator
    please help me
    thnx

  • 45. Michael  |  |  January 22nd, 2007 at 1:30 am

    Hi, I am working on a project and will be using the Mega16 with the STK500 board but the LCD will be a Sanyo DM2023 using the LC7985NA controller. I could not get the test program to work. I was wondering if there are any changes that must be done to your code to be able to produce the same result on the sanyo lcd?
    Thanks!

  • 46. Vibashreya  |  |  January 23rd, 2007 at 5:11 pm

    I am a BE student and we are doing our final project.
    We needed help for interfacing Lcd to our Atmel 89C52 chip.Will u guide us with this interfacing.

  • 47. Bode  |  |  January 27th, 2007 at 5:52 pm

    Hey could you show the code for the function used in teh code above e.g. lcd_init(20);- lcd_init() function or are they built in finction?

  • 48. Farzan  |  |  February 12th, 2007 at 10:47 pm

    Hi!
    I’m going to design a gift using an avr microcontroller for valentines day, can anyone help me?
    I realy don’t know what kind of gift I’ve to design, any suggestion will be useful [;)]
    Specialy thanks for your help in advance.
    plz mail to: farzan.avr@gmail.com

  • 49. Harsh  |  |  February 13th, 2007 at 10:53 am

    I want to know how to display image on the Nokia LCD.I m using PIC
    micro controller for it. Which software did u find for this?

  • 50. amutha  |  |  February 14th, 2007 at 10:17 am

    hi,
    i have done a project on wireless, in which we are using microcontroller, encoder and RF transmitter.

    how to increase the coverage area for transmitter?

    which type of signal will be used while teranmitting in wireless(analog or digital)?
    thank u

  • 51. raj  |  |  February 20th, 2007 at 8:06 am

    i want LCD HD44780 driver (4bit or 8bit interface)for MSP430F147 in IAR IDE

  • 52. MAJID  |  |  March 11th, 2007 at 2:54 pm

    HI ALL
    I HAVE CHARACTER AND GRAPHIC LCD CODE AND SHEMATIC ON AVR STUDIO

  • 53. Gurjeet  |  |  March 22nd, 2007 at 8:26 am

    Hello Majid,
    we are working on graphic LCD interfaced with ATmega8515 which comprises of Atmel AVR core.I m looking for a program that can at least switch on the colour LCD.It is a 320 X 240 colour Lcd of make Lampex.If u have any program of something like that then please do mail it to:
    electronics@prima-automation.com
    or
    gurjeetsinghbhullar@yahoo.co.in

  • 54. Dima  |  |  April 16th, 2007 at 5:33 pm

    Hi,I would like to know,how LCD can help me to read bits that are output of an Eprom,if bits represent minutes ,but I want the LCD to give me them as days hours and minutes.for example if we have 101110011010 this represent 2970 minutes ,so I want LCD to give me 2 :1:30 that means 2 days and 1 hour and 30 minutes.

  • 55. ali r shakeri  |  |  May 9th, 2007 at 9:46 pm

    HI
    please guid me for working with graphical lcd by atmega 8 or 16
    how to configur it,how can i define a word to diplay.
    please send its compilre and simulator in bascam avr.

    thanks a lot

  • 56. Zahra  |  |  May 15th, 2007 at 2:49 pm

    Hi
    I need driver for connecting GRAPHIC LCD to ATMEGA32
    and also want to define some persian font on that.what do I o?

  • 57. Andrea  |  |  May 17th, 2007 at 3:02 pm

    hi…good work…. im impressed..well need help… got a project to built a kitchen scale with strain gauges and display it on lcd… for the display part gotta convert the output voltage of amplifer to digital using microprocessor right…?? need help..im running out of time… which atmel micro should i use?how should i connect it to lcd?didnt buy the lcd yet..can you hook me up with informartion??plz any1 who can help with the strain gauges part hook me up plzzzzzzzzzzzzz ….. im here 207027757@cput.ac.za

  • 58. mahdi  |  |  May 21st, 2007 at 6:33 am

    Hi, who need my help about AVR ADC,LCD and so on?
    mail to me.

  • 59. Rawad  |  |  May 24th, 2007 at 2:23 pm

    Hi All
    I need to connect the LCD graphic with avr micro
    controler by use codevision
    i need some of sit it can help me
    thanks for any help

  • 60. Pascal  |  |  May 28th, 2007 at 2:48 pm

    Hello,

    Many of you seem to be looking for LCDs, code for LCDs, and so
    on. We have 2 LCDs at present, one 101 x 64 1-bit display, which
    is controlled via spi port, and a 128 x 112, 2 bits (4 gray levels)
    which is controlled in parallel. Both LCDs need a 3,3V supply.
    Some people have been porting the source code (included) to AVR, V850, PIC, and probably other types.
    Some other low-power LCDs will be available soon. Stay tuned.

    Pascal

    http://passworld.co.jp

  • 61. lekan  |  |  June 6th, 2007 at 10:38 am

    Pls I am working on a small project for a school,they need an LCD say about 6′’ by 12′’ size connected to one CCTV that has a four(4 way)switcher with an audio system.Pls tell me how can i get such a configuration as soon as possible a i have only on friday to submit my quote.
    Let me know how workable this can be.

    I await your response.
    Best regard,
    Lekan Badejo

  • 62. Affar Shahid  |  |  June 8th, 2007 at 1:17 pm

    Hi, I really liked your LCD explaination however I tried to use your code but my LCD wont work, it has the same controller or its equivalent according to the data sheet as you mentioned, the connections are same as yours, however i dont even see a cursoe or anything, im quite sure its the software because i tried some other examples but they just gave me screen full of black squares. I have been trying this out since 4 days now, i could use your help. i am using the stk500 as well and atmega16. also does it matter whether i have a licensed or freeware version of code vision ? where do the lcd.h functions come from? shouldnt there be a c file for them?

  • 63. simos  |  |  June 11th, 2007 at 12:30 pm

    i have a project in nokia lcd.i want to write my name on nokia lcd..how can i do it??

  • 64. henry  |  |  June 17th, 2007 at 7:25 am

    A very very good site.
    I’m doing a project with Atmega8 + 2*16character LCD + AVR ISP programmer
    I need the schematic, thankq very much
    mail to : zhangxin_86@hotmail.com

  • 65. bilal  |  |  June 19th, 2007 at 5:01 pm

    vry exciting forum . if u can help me in interfacing graphical lcd using 8051 microcontroller

  • 66. kumar  |  |  June 28th, 2007 at 8:40 am

    Regaring the 122X32 lcd display with normal port opearion is working. we got output.now we are trying for I2C with driving the LCD. we are using pcf8575 I/O expander using with rabbit processor. we are able to send commands but phasing errors in biit enabling using with I2C.

  • 67. shkiba  |  |  June 30th, 2007 at 4:47 pm

    hi
    i need to use graphic lcd.
    would you plese sent me how to use and config and program
    with graphiclcd (64*128)

  • 68. m  |  |  July 12th, 2007 at 7:53 pm

    hi
    i’m working by ATMEGA16
    I need the shematic of connecting LCD 2*16 to ATMega16 & program for working that

  • 69. somaye  |  |  July 29th, 2007 at 8:11 am

    hi tnx for this site i need you help i need the source lcd graphic model t6963
    and program by assember or c can you send me this source?

  • 70. rachid  |  |  September 2nd, 2007 at 5:46 pm

    Hi i need a code for a 122×32 graphic display on a atmega32

    if somebody can help me i will give hem 100euro’s

    my email adres is tidelotbalie@hotmail.com

  • 71. fereshteh  |  |  September 2nd, 2007 at 9:10 pm

    hi
    i want to connect graphical lcd (TS12864B-5) TO ATMNEGA16
    plz help me
    thank u
    bye

  • 72. Sheetal Agarwal  |  |  October 3rd, 2007 at 2:28 pm

    want a C compiler Source code for interfacing 4*3 Hex keypad with 8 bit LCD on Pic microcontroller

Leave a Comment

Required

Required, hidden

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Send to a friend

Send to a Friend:





Send to a friend:

Most Recent Posts