In this tutorial let's interface a 16x1,16x2 and 20x4 character display with AVR breakout board. For this tutorial we will require a LCD Breakout.

Basics

LCD can be interfaced with Atmega128 breakout in two modes i.e. 8 bit and 4 bit. Let's interface it in 4 bit mode.We will connect the display in 4 bit mode. You can change it to 8 bit mode making changes in connections and corresponding code. Hardware connections remain same for LCD 16x1,16x2,20x4 as shown in hook up.
Refer 8051 Tutorial for basics of character LCDs

Hook Up

0Interfacing LCDs with Atmega128 Breakout bb.png

Code

LCD 16 x 1

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

LCD 16 x 2

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

LCD 20 x 4

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

Demo

The image below shows 16x2 LCD interfaced AVR breakout.

Interfacing LCDs with Atmega128 Breakout 162.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/ATMega-128-Break-Out-BoardDVB-12007/archive/master.zip


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

Restoring ATmega128 Bootloader

There are lot of weird things about ATmega128, that I will be covering in this tutorial. The end goal is to set it up properly so that it will be useful and save you some time eventually. If...

Setting up ATmega128 Breakout

In this tutorial we will look at the basic setup required to get started with Atmega128 Breakout. After completion of this basic setup we can interface peripherals with the breakout board. ...

Blinky with Atmega128 Breakout

In this tutorial we will get hands on with Atmega128 breakout board. Here we will interface simple LED with one of the port pins. For this tutorial we will require a breadboard, LED and resistor. ...

Switch and a LED with Atmega128 Breakout

Now we will control the LED depending on external input. In this tutorial we will interface a switch to one of the port pin and display its status on LED connected to other port. Basics...