Академический Документы
Профессиональный Документы
Культура Документы
Prepared by:
Eng. Ashraf Darwish
Ashraf.emad.darwish@gmail.com
Session 2
LCD
LCD
Type
2 x 16 LCD
4 x 16 LCD
Graphical LCD
Picture
LCD
LCD
LCD Connection :
LCD
value
PORTA
0x1B
PORTB
0x18
PORTC
0x15
PORTD
0x12
Function
Description
lcd_gotoxy (x,y )
Ex: lcd_gotoxy(3,0)
lcd_clear ( )
Lcd_puts (char*str)
Ex: char x[3]=
{a,b,c}
Description
lcd_putsf (text)
Ex:
lcd_putsf(hello
world !)
Itoa (integer,str)
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