(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:AVR Tutorials]]
 
[[Category:AVR Tutorials]]
 +
=Basics=
 +
We have covered the basics of  character LCDs in the [[LCD_16_x_2_Interfacing_with_8051|8051 Tutorial]]. In this tutorial let's go straight ahead and interface various character display like 16x1, 16x2, 20x4 with AVR atmega32.
 +
Note that most of these displays use a standard display controller like HD44780U, hence a generic code can be written to interface different types mentioned above. Also, these can be interfaced in 4-bit, 8-bit modes.
  
[http://exploreembedded.com/wiki/images/8/88/Schematic_AVR_Interfacing_LCD_16X2_4bit.pdf '''Schematic:4bit mode''']
+
=Hookup=
 +
We will connect the display in 4 bit mode as shown in the diagram below. You may change it to 8 bit and make the required connections and corresponding code changes.   Also note that the Hardware connections remain same for LCD 16x1, LCD 16x 2 and LCD 20x4 configurations. So let's start with 16x1 LCD.
 +
[[File:LCD 16X2 AVR.png]]
  
[[File:Schematic AVR Interfacing LCD 16X2 4bit.JPG|680px]]
+
=LCD 16 x 1=
[http://exploreembedded.com/wiki/images/e/ea/Schematic_AVR_Interfacing_LCD_16X2_8bit.pdf '''Schemati:8bit mode''']
+
<syntaxhighlight>
 +
#include "lcd.h"
 +
int main()
 +
{
 +
    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTC.4 to PORTC.7*/
 +
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PC_4,PC_5,PC_6,PC_7);
 +
    LCD_Init(1,16);
 +
    LCD_DisplayString("Explore Embedded");
 +
    while(1);
 +
    return (0);
 +
}
 +
</syntaxhighlight>
  
[[File:Schematic AVR Interfacing LCD 16X2 8bit.JPG|680px]]
+
=LCD 16 x 2=
'''Code and Explanation will be ubdated soon..'''
+
<syntaxhighlight>
 +
#include "lcd.h"
 +
int main()
 +
{
 +
    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTC.4 to PORTC.7*/
 +
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PC_4,PC_5,PC_6,PC_7);
 +
    LCD_Init(2,16);
 +
   
 +
    LCD_DisplayString("Explore Embedded");
 +
    LCD_DisplayString("Lcd 4-bit Mode");
 +
    while(1);
 +
   
 +
    return (0);
 +
}
 +
</syntaxhighlight>
 +
 
 +
[[File:LCD 16X2 UltraAVR.JPG]]
 +
 
 +
=LCD 20 x 4=
 +
<syntaxhighlight>
 +
#include "lcd.h"
 +
int main()
 +
{
 +
    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTC.4 to PORTC.7*/
 +
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PC_4,PC_5,PC_6,PC_7);
 +
    LCD_Init(4,20);
 +
   
 +
    LCD_DisplayString("Explore Embedded\n");
 +
    LCD_DisplayString("LCD 4-bit Mode\n");
 +
    LCD_DisplayString("20 x 4 \n");
 +
    LCD_DisplayString(":)  :O");
 +
 +
    while(1);
 +
   
 +
    return (0);
 +
}
 +
</syntaxhighlight>
 +
 
 +
[[File:LCD 20X4 UltraAVR.JPG]]
 +
 
 +
 
 +
=Video Tutorial=
 +
For those of you, who would like to watch instead of read we have made a video with all the gyan.
 +
<br>
 +
{{#ev:youtubehd|-lNAmSNV2-Q|640}}
 +
 
 +
 
 +
= Downloads=
 +
Download the complete project folder from the below link:
 +
https://github.com/ExploreEmbedded/ATmega32_ExploreUltraAvrDevKit/archive/master.zip<br>
 +
 
 +
 
 +
 
 +
Have a opinion, suggestion , question or feedback about the article let it out here!
 +
{{DISQUS}}

Latest revision as of 15:10, 1 September 2016

Basics

We have covered the basics of character LCDs in the 8051 Tutorial. In this tutorial let's go straight ahead and interface various character display like 16x1, 16x2, 20x4 with AVR atmega32. Note that most of these displays use a standard display controller like HD44780U, hence a generic code can be written to interface different types mentioned above. Also, these can be interfaced in 4-bit, 8-bit modes.

Hookup

We will connect the display in 4 bit mode as shown in the diagram below. You may change it to 8 bit and make the required connections and corresponding code changes. Also note that the Hardware connections remain same for LCD 16x1, LCD 16x 2 and LCD 20x4 configurations. So let's start with 16x1 LCD. LCD 16X2 AVR.png

LCD 16 x 1

#include "lcd.h"
int main() 
{
    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTC.4 to PORTC.7*/
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PC_4,PC_5,PC_6,PC_7);
    LCD_Init(1,16); 
    LCD_DisplayString("Explore Embedded");
    while(1);
    return (0);
}

LCD 16 x 2

#include "lcd.h"
int main() 
{
    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTC.4 to PORTC.7*/
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PC_4,PC_5,PC_6,PC_7);
    LCD_Init(2,16);
 
    LCD_DisplayString("Explore Embedded");
    LCD_DisplayString("Lcd 4-bit Mode");
    while(1);
 
    return (0);
}

LCD 16X2 UltraAVR.JPG

LCD 20 x 4

#include "lcd.h"
int main() 
{
    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTC.4 to PORTC.7*/
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PC_4,PC_5,PC_6,PC_7);
    LCD_Init(4,20);
 
    LCD_DisplayString("Explore Embedded\n");
    LCD_DisplayString("LCD 4-bit Mode\n");
    LCD_DisplayString("20 x 4 \n");
    LCD_DisplayString(":)  :O");
 
    while(1);
 
    return (0);
}

LCD 20X4 UltraAVR.JPG


Video Tutorial

For those of you, who would like to watch instead of read we have made a video with all the gyan.


Downloads

Download the complete project folder from the below link: https://github.com/ExploreEmbedded/ATmega32_ExploreUltraAvrDevKit/archive/master.zip


Have a opinion, suggestion , question or feedback about the article let it out here!