Académique Documents
Professionnel Documents
Culture Documents
You can send the data as an ASCII code character and the
LCD controller will display the character
You can send commands:
e.g. :clear display, cursor home, ...
the controller has two modes:
8 bit mode: data is sent through 8 bits DB0-DB7
4 bit mode: data is sent through 4 bits DB4-DB7
two phases to send data: 4 bits at a time
LCD mikroC Library
Fortunately, mikroC has a library for LCD
This library uses the 4-bit mode
Information is available through help
You need to configure the port connected to the LCD
Functions:
Lcd_Out(r, c, text) : display a text starting from row r and column c
Lcd_Out_Cp(text) : display a text on current cursor position
Lcd_Chr(r,c, ch) : display a character on row r and column c
Lcd_Chr_Cp(ch) : display character on current cursor position
Lcd_Cmd (cmd) : send a command, e.g. _LCD_CLEAR
LCD mikroC Library - Configuration
voidmain()
{
Lcd_Config(&PORTB,0,1,2,6,5,4,3);
Lcd_Out(1,1,"Anis");
Lcd_Cmd(LCD_CURSOR_OFF);
while(1)
{
}
}
Exercise: Display your name and make it scroll across the LCD
Example
Circuit design:
Example - Program
voidmain()
{
intx;
chars[8];
Lcd_Config(&PORTB,0,1,2,6,5,4,3);
Lcd_Out(1,1,"Count:");
IntToStr(x,s);
Lcd_Out(1,8,s);
Lcd_Cmd(LCD_CURSOR_OFF);
x=0;
TRISA.F0=1;
while(1)
{
if(PORTA.F0==1)
{
x=x+1;
while(PORTA.F0==1);
IntToStr(x,s);
Lcd_Out(1,8,s);
}
}
}