Using LCD Module with AVRs
When you start working with LCD modules you will start feeling the real power of MCU and your imaginations will be touching sky you will wonder how many exciting a powerful gadgets you can create and that’s so very easily.
LCD Modules can present textual information to user. It’s like a cheap “monitor” that you can hook in all of your gadgets. They come in various types. The most popular one can display 2 lines of 16 characters. These can be easily interfaced to MCU's, thanks to the API( Functions used to easily access the modules) we provide. LCD interfacing is just fun !
![]() |
Fig: A 16x2 LCD Module |
PIN Configurations.
The lcd modules has 16 PINs for interfacing. The details are given below.
| LCD Module Pin Configuration |
| 1 VSS (GND Supply) |
| 2 VCC (+5V) |
| 3 VEE (Contrast Adjust) |
4 RS |
5 R/W |
6 E |
7 DB0 |
8 DB1 |
9 DB2 |
10 DB3 |
11 DB4 |
12 DB5 |
13 DB6 |
14 DB7 |
15 LED + |
16 LED - |
Connection with Board MINI.
The lcd module can be easily connected to the Board™ MINI the connection is as follows.
Fig: Connection |
Adding LCD support to your project
To add LCD support to your C projects we have made a easy to use library. To use this library first create a new project in AVR Studio then copy the following files to your project folder. lcd.c lcd.h myutils.h from x:\xAPI\lcd-v20\ (where x:\ is your CD/DVD drive) then add them to your project by right clicking project view and selecting “Add Existing Source File(s)…” and then select the “lcd.c”. Similarly add “lcd.h” and “myutils.h” in Header Files section. Now you are ready to start coding LCD applications !!!
Fig: Adding files to projects. |
Programming.
In your main C file include the file lcd.h as #include “lcd.h” then initialize the LCD subsystem using a call to LCDInit(LS_BLINK|LS_ULINE); the argument specify the type of cursor required the LS_BLINK gives a blinking cursor. LS_ULINE gives a underlined cursor. To write any text call LCDWriteString("Welcome"); To write any number call void LCDWriteInt(int val,unsigned int field_length); This will print a integer contained in “val” . The field length is the length of field in which the number is printed.
For example LCDWriteInt(3,4); will print as follows
While LCDWriteInt(123,5) will print as follows.
To goto any particular position on screen call.
| void LCDGotoXY(uint8_t x,uint8_t y); |
| LCDGotoXY(11,1); |
Fig: Cursor Positioning. |
Now anything you write to LCD will be printed at (11,1).
Clearing the display
| LCDClear(); |
LCDWriteStringXY(x,y,msg); ____________________________ x,y : the location where to print “msg” msg : the message to print Ex: LCDWriteStringXY(3,0,”hello”); LCDWriteStringXY(8,1,”world”); Output:
|
LCDWriteIntXY(x,y,num,field_length); ____________________________________ x,y : the location where to print “num” num : the integer number to print field_length : the length of field (see LCDWriteInt() function above). |
Sample Program
#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"
void main()
{
unsigned char i;
//Initialize LCD module
InitLCD(LS_BLINK|LS_ULINE);
//Clear the screen
LCDClear();
//Simple string printing
LCDWriteString("Congrats ");
//A string on line 2
LCDWriteStringXY(0,1,"Loading ");
//Print some numbers
for (i=0;i<99;i+=1)
{
LCDWriteIntXY(9,1,i,3);
LCDWriteStringXY(12,1,"%");
_delay_loop_2(0);
_delay_loop_2(0);
_delay_loop_2(0);
_delay_loop_2(0);
}
//Clear the screen
LCDClear();
//Some more text
LCDWriteString("Hello world");
LCDWriteStringXY(0,1,"By YourName Here"); // <--- Write ur NAME HERE !!!!!!!!!!!
//Wait
for(i=0;i<100;i++) _delay_loop_2(0);
//Some More ......
LCDClear();
LCDWriteString(" eXtreme");
LCDWriteStringXY(0,1," Electronics");
}
Advance Use – Configuring Connections.
The library is designed to be fully customizable. If you want to connect the LCD module to some different i/o ports of the MCU then you can do so easily. You just have to modify the lcd.h file. Let’s see how. Open lcd.h and find a section “LCD Connections” it looks like
Fig: Configuring LCD Connection. |
Set LCD_DATA to the port where you have connected the LCD data lines. Data Lines must be connected to any port say PORTB starting from pin-0 to pin-3. i.e. If you set #define LCD_DATA B you should connect like this :
PORTB.0->DATA4 PORTB.1->DATA5 PORTB.2->DATA6 PORTB.3->DATA7
The library uses advance 4-bit mode so DATA0-DATA-3 of LCD are not used, saving 4 MCU pins! Now set the port where you have connected LCD’s ‘E’ signal. In example it is PORTD so #define LCD_E D Then specify to which PIN of PORTD it is connected, this is done by #define LCD_E_POS PD6 So ‘E’ pin of LCD is connected to PORTD-6 In same way set RS and RW signals. And that’s all! So you saw how easy is to customize the library.
Downloads
Download this tutorials with all required files.(library and sample code included)
What's next ??? |
| We will see what different Internal peripherals available on the AVR mcu and the methods of interface/communication from them. This will help you use internal peripheral like ADC,Timers,USARTs etc which will be covered in later tutorials. |
Have fun and don’t forget to bookmark this page. If you think this tutorial has helped you please post a comment.


Thanks for the tutorials n carry on… rest assured there are many people learning something from them! Can’t wait for the next articles!
July 28th, 2008 at 9:53 am[...] ForLCD Interfacing See- “LCD Interfacing Tutorial” [...]
September 18th, 2008 at 12:22 pm[...] the key code of the various keys on your remote control. To learn more about LCD interface with AVRs see this. The connection is different for ATmega8 and ATmega16/32 so I am giving both [...]
November 2nd, 2008 at 9:52 amWhy is this lcd display being operated using 2 ports? Can it be set up to use only one?
December 3rd, 2008 at 5:12 amOops i’m an idiot. This site was very helpful, THANKS!
December 3rd, 2008 at 5:32 amwonderful site, but your css-layout seems to be broken on
December 6th, 2008 at 12:37 amhttp://extremeelectronics.co.in/avr-tutorials/using-lcd-module-with-avrs/
(tables are not displayed correctly!)
@bla
Hi,
Thanks for reporting! Ya the content just now looks horrible!!! Yesterday I applied a new theme and due to lack of time cannot complete it properly.
I will clean everything soon.
December 6th, 2008 at 7:08 am@bla
I have edited the page, now the layout is much better and readable.
December 13th, 2008 at 11:37 am[...] Using LCD Modules with AVRs. [...]
January 11th, 2009 at 10:30 amHi,
January 13th, 2009 at 1:08 pmI managed to burn the hex file onto the MCu but im unable to see the output on the LCD. how can i fix this?
Check the following
1)The Code is for ATmega8 MCU
2) See the connection section in lcd.h file and confirm that they are same as the physical connection u made.
3)Connect a 10K POT between Vcc and GND and the centre PIN to PIN 3 of LCD (contrast) and adjust it till chars are visible. But as in circuit above u can also GND this PIN.
4)Pls check all connection
We can discuss further on this in forum
January 13th, 2009 at 5:11 pmhttp://forum.extremeelectronics.co.in/viewforum.php?f=2
Thanks for the Tutorials… I need a help that how the data trnasmitted to LCD and where the data is stored to display on the LCD.Pls kindly clear my doubt by explaining the transfer of data to LCD…
January 16th, 2009 at 10:54 amHello Pooja
To know the internals pls explore the source code and see this link
http://forum.extremeelectronics.co.in/viewtopic.php?f=3&t=9
January 16th, 2009 at 12:21 pmHi.
Thanks! After trying out like 6 other lcd libraries out there on my ATMEGA-128 @ 16Mhz, yours is the only one I could get to work! Thanks!
January 20th, 2009 at 2:37 amHello Jonathan,

January 20th, 2009 at 9:02 amNice to meet you! I am happy that my codes are helping peoples.
Avinash: Great library! Easy to use and modify. A question, however: How can I print the value of a variable, such as the character contained in the serial UDR register, to the LCD?
January 29th, 2009 at 1:52 amHello Levitis,
Yes you can print the content of a varriable.
1)char type : USE function LCDData(char_varriable);
2)int type see: LCDWriteInt() & LCDWriteIntXY() functions.
Have a nice day !
January 29th, 2009 at 8:22 amThank you very much!
February 20th, 2009 at 12:36 pmHow can i configure the library file to use it with a 4 lines 20 characters LCS?Please any help.
Hello,
The 4 line modules are actually 2 LCD module pack into one.
February 20th, 2009 at 12:45 pmI think they are accessed like two different modules. They have 2 HD44780 controllers in them.
Can u explain the functions that you wrote in the lcd.h file..
February 27th, 2009 at 12:06 pmIt helped me a lot, thanks. You are doing a good job
March 4th, 2009 at 2:37 amDear Avinash,
March 8th, 2009 at 3:34 pmWhen i am compling your code it is giving 5 errors and it is saying that “lcd.h : no such file or directory exist” what should i do…
[...] program demonstrate the use of external EEPROM interfaing functions. The program makes use of the LCD library for AVRs to display information in a 16×2 LCD display. The program first writes 8Kbytes of data to a 24c64 [...]
March 20th, 2009 at 1:19 pmin this statement how to select portb(4-7) instead of 0-3?
#define LCD_DATA C //Port PC0-PC3 are connected to D4-D7
code is very useful. Thank you..
March 28th, 2009 at 11:30 amGreat ideas, is there a place to elaborate on this all?
April 3rd, 2009 at 6:56 amWew..thx bro! this lib is very helpful!!! now i can working on my final project…..lol
April 3rd, 2009 at 2:43 pmLa pagina es espectacular, soy fanatico de los AVR…
en su sitio he encontrado cosas muy buenas!!
Thanks…
April 20th, 2009 at 7:24 amSaludos desde CHILE!!!
can we do the program for LCD through WINAVR for ATMEGA16??????????????????
May 16th, 2009 at 6:18 pm@SANTOSH
SO WHAT IS THE THAT LONG PAGE ABOUT ???
DON’T POST SUCH SILLY QUESTIONS!
May 17th, 2009 at 7:56 ammy lcd data pins are connected to portb as
DATA 4 – PINB 4
DATA 5 – PINB 5
DATA 6 – PINB 6
DATA 7 – PINB 7
can you give the right modification in lcd.h connection
May 24th, 2009 at 1:49 am@ Sanjay
Tell me the position of RS/RW/ and E Pins
also the MCU in use
Currently you can only use LOWER NIBBLE OF A PORT (i.e. bit 0-3) for data port.
And you are trying to use higher nibble (i.e. bit 4-7) which is NOT possible.
Thankyou.
May 24th, 2009 at 7:01 amthe pin cinfiguration is as
May 24th, 2009 at 10:38 amRS – PB.0
RW – PB.1
EN – PB.3
D0 – PB.4
D1 – PB.5
D2 – PB.6
D3 – PB.7
and working in 4bit mode
Thanks for your tutorial,
I have some question about your tutorial, I’ve been used codevision avr before, and now migrate to winavr, my LCD data port belong to PORT C4, C5, C6, C7
how to set my data port in your lcd.h ?
May 25th, 2009 at 5:59 amFirst of all……thank you very very much Avinash. Brilliant job with the tuts. Hats off….
I did try this out with ATmega8 and it worked A ok.
But now want to try this out with ATmega32 and the code doesnt seem to work.
Before trying it out with ATmega32 i did chance the code in lcd.h file like shown below.
But i don’t seem to get any o/p.
Can you please help and tell me why this code only works for ATmega8 and not ATmega32 ?
#define LCD_DATA C //Port PC0-PC3 are connected to D4-D7
#define LCD_E D //Enable OR strobe signal
#define LCD_E_POS PD6 //Position of enable in above port
#define LCD_RS D
#define LCD_RS_POS PD4
#define LCD_RW D
May 25th, 2009 at 9:27 pm#define LCD_RW_POS PD5
@Varun
May 26th, 2009 at 4:18 pmYes it works with ATmega8/16/32 and many more. Just check the CPU speed you set. In AVR Studio Give exact CPU frequency(crystal) in actual use.
Thank tou very much Avinash.
I have tried it but it did not work. I am using AVR Studio for an ATMEGA8.
When I try to Build the project there are two errors:
“… Section .text will not fit in region text”
and
“… region text overflowed by 3506 bytes”
Please, could you help me with this?
Thank you
June 24th, 2009 at 1:38 am@Andriu,
The problem is that you have OPTIMIZATION turned off. Go to Project->Configuration and change optimization to O2. And report to me if it solved the problem.
June 24th, 2009 at 6:16 amYou were right, now it is built, but nothing is written in the LCD.
It seems to write only the first line and a few seconds later, it seems to write the two lines of the LCD but there are no characters, all the points get black.
I have a 10K pot and move the contrast but it does not work. Either it is all white or all black, the characters are not printed.
In project options I have selected FREquency 12000000 Hz. Is it correct?
Thank you again for your time
June 25th, 2009 at 12:08 amHello,
I have been trying and I can not make it work.
I have connected ENABLE at PB5, RS at PB4 and RW at PD7.
Can be there the problem? Should I connect all of them to the same port?
Thank you, Avinash
July 1st, 2009 at 12:33 am@Andriu,
What is the freq of crystal u r usin?
July 1st, 2009 at 10:16 amand tell me the details of connection (all pins)
I am using STK500 and I amtrying to make it work at 1 MHz.
I have changed in lcd.c and lcd.h: #define F_CPU 1000000UL
In Project, Configuration options, Frequency: 1000000 Hz
and when I program I select:
– Fuses: Internal RC osc 1Mhz (I have also tried Ext. Clock)
Connections:
PB0 –> data 4 (11 in LCD)
PB1 –> data 5 (12 in LCD)
PB2 –> data 6 (13 in LCD)
PB3 –> data 7 (14 in LCD)
PB4 –> RS (4 in LCD)
PB5 –> ENABLE (6 in LCD)
PD7 –> RW (5 in LCD)
The first line of the display is black and the second is white.
July 1st, 2009 at 10:05 pmI have repeated the assembly with a new LCD and new cables and the same is happening again. I guess I am forgetting something.
@Andriu,
Have u edited the lcd.h file’s connection section ???
July 2nd, 2009 at 11:12 amYes, I have edited the lcd.h file. This is the text:
#ifndef F_CPU
#define F_CPU 1000000UL
#endif
…
#define LCD_DATA B //Port PB0-PB3 are connected to D4-D7
#define LCD_E B //Enable OR strobe signal
#define LCD_E_POS PB5 //Position of enable in above port
#define LCD_RS B
#define LCD_RS_POS PB4
#define LCD_RW D
July 2nd, 2009 at 9:37 pm#define LCD_RW_POS PD7
hey nice tutorial avinash….
July 13th, 2009 at 9:32 pmif i connected the lm 35 to adc0 and humidity sensor to adc1 how to write the code for it can you help me for this
Avinash,
thank you very much. At last I managed to make it work. I do not know why (your code seems to me all right), the atmega was in an infinite loop when I called to InitLCD().
I have changed in function void LCDBusyLoop() the condition while (busy) for while(busy==0×00) to force it to leave the loop. And in main() I write
InitLCD(LS_ULINE);
LCDClear();
LCDWriteStringXY(0,0, ” “);
LCDWriteStringXY(0, 0, “Hello World”);
Somehow it works.
July 16th, 2009 at 3:10 amAgain, thank you very much for the code and for your answers.
Best regards from Spain
Avinash,
July 25th, 2009 at 9:37 amThanks a lot for your nice working Tutorial. I have become successful in LCD programming using ur files..
A little problem is that it sometimes does not want to start instantly. After switch off/on of power, it then starts….Why is that..?
Hy!
Thank you for these gresat tutorials.
I have managed to get my 2X16 LCD to work on PORT B, but I noticed that I need that port for other things(on Atmega 16).
I’ve connected the LCD to PORT C:
PC 0-3 to LCD 11-14
PC4 – RS
PC5 – RW
PC6 – E
I also edited the lcd.h as it follows:
#define LCD_DATA C //Port PC0-PC3 are connected to D4-D7
#define LCD_E C //Enable OR strobe signal
#define LCD_E_POS PC6 //Position of enable in above port
#define LCD_RS C
#define LCD_RS_POS PC4
#define LCD_RW C
#define LCD_RW_POS PC5
The lcd doesn’t working, it shows only the first line with all points on.
July 25th, 2009 at 11:52 pmI have also checked the connections with a multimeter. Everything is ok.
Please help me!
@Andrei
While using PORTC in ATmega16 you need to disable the JTAG functionality which is by default enabled on the ATmega16.
July 25th, 2009 at 11:59 pmSee that u have disabled the JTAG functionality first.
To disable the JTAG u need to change the high fuse bits…
Thanks for the respone. but it still doesn’t work.
July 26th, 2009 at 12:55 pmI have disabled the JTAG option and the result is the same.
..with AVR Burn-o-mat i wrote D9 on hfuse
..and another thing, if i reset the MCU, one time lcd displays one line full oh pixels, and other time it shows 2 lines. I don’t know what is the problem.
July 26th, 2009 at 12:59 pm@Andrei
July 26th, 2009 at 1:01 pmplease tell ur gmail id.
R u able to do that with other ports
July 26th, 2009 at 1:02 pmI have only an yahoo account bboyandru
July 26th, 2009 at 1:04 pmand yes, with port B it worked
July 26th, 2009 at 1:05 pmIt ain’t working anymore, neither with PORT B
July 26th, 2009 at 1:24 pmYes!!!!
It is working, on PORTC too, thank you so much for your time.
The problem was that in lcd.c I have modified LCDBusyLoop function as mentioned above ( while(busy==0×00) ). I replaced with while(busy) as Avinash wrote first and is working. And with PORT C the problem was with disabling JTAG.
Thank you so much!
July 26th, 2009 at 1:45 pmHey just wanted to check whether the LCD display you are using uses a HD44780 controller or a KS0066 controller.
And also to check if you know whether there are any differences between them.
Thanks
August 4th, 2009 at 7:29 am@Trandy
They are HD44780 based
August 4th, 2009 at 9:06 amhi thanks a lot buddy!
I have a small question please, I did all the connections properly and compiled your sample program successfully. I also accordingly changed the 12000000UL to 16000000UL in both the c file and the header file (libraries) since I’m using an external 16MHz crystal.
My problem is that it shows all black on the first line in each box. I have no idea why, any ideas?
thanks man
September 1st, 2009 at 10:05 amoh btw im using the atmega32. This is for a uni project im working on so it needs an lcd and I was lucky I found yours
thank you!
September 1st, 2009 at 10:06 amHey Man (Krishan),
Do u think you can use the external crystal by just hooking the crystal to MCU? Also pls see above comments, u need to disable JTAG to use PORTC on ATmega32
September 1st, 2009 at 10:13 amHi!
The external crystal is connected to the mcu. Yes sure thanks I’ll disable the JTAG on the atmega32 via the fuse bits and see what happens.
btw that was a fast reply
September 1st, 2009 at 10:23 amDude you are the best! it works!! The jtag was the issue
Also I just want to confirm in your tutorial it says that: LCDWriteInt(int val,unsigned int field_length);
val is a integer value, whatever that may be, will be displayed. So if I had a global value named ‘distance’ instead of ‘val’ (since my project calculates distance), whatever value that the program calculates and stores into distance it would be displayed on the lcd.
September 1st, 2009 at 10:47 am[...] program use our LCD driver library more details of which can be found in here. Use avr-gcc + AVR Studio to [...]
September 17th, 2009 at 11:05 amhow do i add header files in case i m using winavr(programmers notepad n makefile) instead of Avrstudio..??
September 20th, 2009 at 2:03 pm@Krishna No need to add headers files just put then project dir
September 22nd, 2009 at 11:01 amNice Tutorial.Well i am one of those who has this problem, especially with portC and my jtag fuse is disabled but the problem remains.I have atmega32 with external crystal 8 mhz and using AVRSTUDIO 4 .I am sure that i have disabled JTAG fuse bit but if i am wrong here are my fuse bits : hbits are 0xD9 and lowbits 0xFD.I need immediately to use portc for Lcd only!With other ports there are no problems, its working well!Any help and reply if possible…
September 30th, 2009 at 11:28 pmThanks
@Kostas
October 1st, 2009 at 8:30 amUse High Fuse = 0xC9 and Low Fuse = 0xFF
hey buddy! just would like to say many thanks for the libraries, they work great.
I just have a question please. Here’s a small snippet of code.
int main(void)
{
// Initialize the LCD
InitLCD(LS_BLINK|LS_ULINE);
//Clear the screen
LCDClear();
welcome(); // Welcome the user to the device
// Initialization code here for the timers and some variables
sei(); // Enable global interrupts
for(;;)
October 1st, 2009 at 8:40 pm{
// Would like some code to run here
}
return 0;
}
My question is that the function welcome() displays my name, and then the name of the project perfectly, however after that no code in the infinite for(;;) loop runs. I would liked to have some calculation routine there however if the LCD libraries are enabled (that is, not commented out) the for(;;) loop and the code inside it won’t run. However if the libraries initialization are commented out then access to the for(;;) loop is restored and code in it runs.
I noticed this on the built-in debugging (im using atmega32 with the simulator also being being atmega32 within avrstudio). Also in practice, the code that was in the for(;;) routine never ran.
During debugging, when the simulator comes to the line:
InitLCD(LS_BLINK|LS_ULINE); <–
AVRStudio then switches to LCD.c towards start of the line:
initLCD(unint8_t style)
Then when F11 is pressed again to resume debugging it goes to the delay_basic.h file to the line:
October 2nd, 2009 at 3:40 am_delay_loop+_2(uint16_6 __count)
Then when F11 is pressed again it goes to the delay.h line to the _delay_ms(double_ms) function. It’s here that it is forever stuck in the while loop:
while(__ticks)
{
_delay_loop_2((F_CPU)/4e3) / 10);
_ticks–;
{
So I think this is probably the reason why any code in the for(;;) routine in the main function never runs. Any ideas? Please help thank you…
PS: Sorry for bridging the question over 3 posts, I didn’t think it would allow the post to be all in one.
October 2nd, 2009 at 3:41 amhii
October 3rd, 2009 at 8:46 amavinash thanks for the tutorial..
i m trying this api for atmega16l..
what should be the frequency of mcu and what will be the fuse bits corresponding to that frequency..
hi
October 4th, 2009 at 1:59 pmthnx for your gr8 tut
ihave some problem
the pin cinfiguration I used is as
RS – PB.0
RW – PB.1
EN – PB.3
D0 – PB.4
D1 – PB.5
D2 – PB.6
D3 – PB.7
and working in 4bit mode
where do i have to make changes in the lcd.h file for the data pins and what should i write
plz urgent
Hmm….Ainstain said that two things are infinite: the universe and human stupidity; and I’m not sure about the universe.I fixed it ,it was in front of my eyes, hardware problem.The DIP connector i used for PORTC it was backwards etc:Port0-port1….ground-Vcc for the other ports and for portC were Port7-Port6…ground-Vcc.Well i deserve the title “the ..rk of the week”:P.Thanks for your quick answer Avinash and keep your great work going on and on.
October 7th, 2009 at 3:35 amhey avinash i want to print the degree symbol on the lcd..plz could you help me wid that..thanking..waiting for your reply…
October 15th, 2009 at 2:55 pmHey avinash…..Your lib worked great on 16×2 LCD…..i was wondering whether i cud use the same lib for a 16×4 LCD module…
October 16th, 2009 at 4:05 pmwhy I cant access the forum.extreem electronics
October 22nd, 2009 at 4:06 pm@Monang
Some hacker attacked the server and injected malicious code in it so I have to stop the site. I will restart it once every thing is corrected. It was very horrible experience.
October 22nd, 2009 at 5:46 pmSir,
Your way of teaching AVR is awesome…. I did not read any text book but understood AVR and able to use it for my projects.
I have problem with the LCD library that you have provided on the website. My problem is my LCD is connected to port B and I want to change the library code for it. The LCD uses databits D0-D3. The connections are made as follows-
RS-PB.0
RW-PB.1
EN-PB.3
D0-PB.4
D1-PB.5
D2-PB.6
D3-PB.7
In the library code it is given that Px.0-Px.3 should be connected to D4-D7 of LCD. But my development board does not allow that. So please tell me how to connect PB.4-PB.7 pins of AVR to LCD’s D0-D3 data pins.
Thank You
October 22nd, 2009 at 10:41 pm[...] LCD Interfacing library for Atmel AVR MCUs [...]
October 23rd, 2009 at 10:45 amHI Avinash,
This tutorial is of great use.
I have a small question, I am trying to display characters on lcd sent via serial port. But when i send ‘a’, lcd displays ‘97′. Can you tell me how to convert ASCII to letter to display ‘a’.
My code is:
data = USARTReadChar(); //reads the letter
itoa(data,buf,16); //converts to ASCII
send_lcd_str(buf); //this function displays only strings
Thanks.
October 23rd, 2009 at 4:01 pm@Jimi
The code will be like this
char data[2];
data[0] = USARTReadChar(); //reads the letter
data[1]=’\0′;
send_lcd_str(data); //this function displays only strings
October 23rd, 2009 at 6:17 pmHey avinash…..Your lib worked great on 16×2 LCD…..i was wondering whether i cud use the same lib for a 16×4 LCD module…
October 31st, 2009 at 11:00 amAvinash,
I was hoping you could elaborate more on your comments below. I would also like to use these libraries to control a 4X20 LCD and don’t really know where to start in editing the libraries.
Avinash Says:
November 6th, 2009 at 11:29 amHello,
The 4 line modules are actually 2 LCD module pack into one.
I think they are accessed like two different modules. They have 2 HD44780 controllers in them.
February 20th, 2009 at 12:45 pm
hello avinash,
November 6th, 2009 at 12:42 pmyour library is very easy to us,i use it for interfacing 16*2 lcd module but for 16*4 its not working.plz help to use it with 16*4 .
Dear Avinash,
November 29th, 2009 at 11:17 pmThis page and your code was very helpful. I’ve got an LCD module working on PORTB of an ATTiny2313. Can you help with the following. I would like to turn the cursor off. I looked up the codes for the HD44780 and found the cursor off code. I tried adding the following to lcd.h
#define LS_NONE 0B00000000
Then I initialised the lcd with InitLCD(LS_NONE);
I still get both a flashing and underlined cursor. Is there any way to turn it off?
@Ian
I also tried to give command as per the datasheet but could not turn off the cursor. I don’t know whats the problem. If you find a solution please share with me. Thanks
November 30th, 2009 at 8:19 amHello Avinash,
November 30th, 2009 at 5:31 pmYou said you have two different codes for ATMega8 and ATMega16/32
I am using ATMega16 so can you give the code or I can use ATMega8 code with some changes . I have already made some changes as per your tutorial. But I am using same lcd.c, “lcd.h” and “myutils.h file with only these changes:
LCD CONNECTIONS
*************************************************/
#define LCD_DATA B //Port PB0-PB3 are connected to D4-D7
#define LCD_E B //Enable OR strobe signal
#define LCD_E_POS PB4 //Position of enable in above port
#define LCD_RS C
#define LCD_RS_POS PC7
#define LCD_RW C
#define LCD_RW_POS PC6
Is it correct or I need to change something else also
hey avinash ,
December 1st, 2009 at 3:17 pmmy comment is still in waiting …..would you please accept it.
Please help my program is not working .
Hey I am sorry avinash , m new in this field ….but I didnt found ATMega16 code in your tutorial ….as you said you have written codes for ATMega16 also . can you please send me that link .
If there is no code in your tutorial then is it possible to make some changes in ATMega8 code to use in ATmega16.
thanking you
December 1st, 2009 at 4:09 pmSeema
Hi, great website and library
I found that cursor does’t react to ULINE and NONE(as was said), so I looked at lcd datasheet, and found that function set command have to be befor.
so int the LCDInit(…) write
LCDCmd(0b00101000);//function set 4-bit,2 line 5×7 dot format
LCDCmd(0b00001100|style);//Display On
and it works perfectly
thank’s
December 6th, 2009 at 6:18 pm@Sarunas
Many thanks for solving the problem. I will try it out.
December 6th, 2009 at 6:45 pmAvinash
thats really cool as your others. But is seems to me your library doesnt work for the blue lcd. its ok for the green.
December 24th, 2009 at 10:21 pmIs the blue differ from green except led color?
@Rohan
It works flawlessly on BLUE LCDs too !!! I have tested with many modules.
December 25th, 2009 at 9:01 amJust use your Common Sense and you will get it working (I won’t give a silly tip so as how to use blue LCD as any one with brain can figure it out in less than 2 minute)
Hello Avinash ,
HAPPY NEW YEAR and may god you and fulfill your dreams. hey avinash I didnt found atmega16 code for LCD display . would you please help me to get a code for atmega16 . m using 2×8 and 2×16 lcd display . In your tutorial its given only for atmega8 .
January 7th, 2010 at 2:27 pmthanking you
@Seema
Its for all AVR so will work with ATmega16 too !
January 8th, 2010 at 9:13 amhey avinash….
good work man…do you have any thing with LCD connected to RS-232. so that I can send data from PC to LCD.
Ritesh
January 12th, 2010 at 2:16 pmritesh Says:
January 12th, 2010 at 8:12 pmhey avinash….
good work man…do you have any tutorial with LCD connected to RS-232. so that I can send data from PC to LCD.
Ritesh
Thx,it works great! Finally!
Can u tell me how to make scrolling text?
February 1st, 2010 at 1:15 amhello avinash….
March 5th, 2010 at 10:42 amthank u coz u r very helpful…
i hav interfaced 3 circuits(metal detector,natural gas detector,temperature detector) to atmega8 and this atmega8 controller is interfaced with gsm modem for sendin message to mobile phone when any 1 of the circuit o/p is positive….
i.e…when metal/gas is detected we should get sms to our mobile…but regarding temperature after 30 seconds from the time we switch on the controller,wat ever temperature is detected we should recieve sms…pls help me with program…