100% found this document useful (2 votes)
80 views18 pages

AVR Microcontroller: Prepared By: Eng. Ashraf Darwish

This document discusses interfacing an AVR microcontroller with an LCD display. It provides information on different LCD types and sizes, and describes how to connect an LCD to the microcontroller. The document explains how to initialize and control an LCD using functions in the LCD library in CodeVision. It provides examples of writing text and numbers to the LCD, including converting integers to strings. Finally, it gives examples of coding a counter and timer that display updated values on the LCD.

Uploaded by

HectorLopez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
80 views18 pages

AVR Microcontroller: Prepared By: Eng. Ashraf Darwish

This document discusses interfacing an AVR microcontroller with an LCD display. It provides information on different LCD types and sizes, and describes how to connect an LCD to the microcontroller. The document explains how to initialize and control an LCD using functions in the LCD library in CodeVision. It provides examples of writing text and numbers to the LCD, including converting integers to strings. Finally, it gives examples of coding a counter and timer that display updated values on the LCD.

Uploaded by

HectorLopez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

AVR Microcontroller

Prepared by:
Eng. Ashraf Darwish

[email protected]

Session 2

Interface with LCD


Interface with keypad
C programming review
Examples

LCD

LCD stands for Liquid crystal


Display
There are many types and sizes of
LCD
In our course we will deal with 2 x 16
( two lines each of 16 digit )

LCD
Type

2 x 16 LCD

4 x 16 LCD

Graphical LCD

Picture

LCD

In our course we will deal with Hitachi


2 x 4 LDC

LCD
LCD Connection :

LCD

How to deal with LCD in


Codevision ?
you should #include <LCD.h>
this library contains all LCD functions
2. You should select the port of AVR which
be connected to your LCD, to do this
you have two write assembly order
#asm
.equ __lcd_port=0x15; // to choose portC
#endasm
1.

How to deal with LCD in


Codevision ?
To select another ports :
PORT

value

PORTA

0x1B

PORTB

0x18

PORTC

0x15

PORTD

0x12

How to deal with LCD in


Codevision ?
3.
4.

Initialize your LCD :


lcd_init(16)
LCD functions:

Function

Description

lcd_gotoxy (x,y )
Ex: lcd_gotoxy(3,0)

Move the curser to the place (column x , line


y)
Your text will starts at the third column and
first line

lcd_clear ( )

To clear the data on the display

Lcd_puts (char*str)
Ex: char x[3]=
{a,b,c}

To write character on your LCD

How to deal with LCD in


Codevision ?
Function

Description

lcd_putsf (text)
Ex:
lcd_putsf(hello
world !)

To write string on LCD

Itoa (integer,str)

Converts integer to string , so you can


display it on LCD

Important Note
LCD can display variables of type
char , so of we need to display
integers we have to use the following
function:
#include <stdlib.h>
Itoa (integer , string );

Example
Ex #1 :
Write counter code which count from 0
to 9 and restarts to 0 again and
display your results on LCD

Example
Sol :
1. include your needed header files
#include <mega16.h>
#include <lcd.h>
#include <delay.h>
select your LCD port , lets say Port C
#asm
.equ __lcd_port=0x15 //Port C
#endasm
2.

Example
3.

main functoin
void main ( )

{
4. Variables

Ports declaration
5.While

(1)

{
your code here
}
}

Example

Example
Ex #1 :
Write countdown timer on LCD that
counts from 9 to 0 and returns to 9
again

Example
Ex #1 :
Write countdown timer on LCD that
counts from 9 to 0 and returns to 9
again

You might also like