Header Ads

Interfacing 16x2 LCD with PIC16C77 Microcontroller

Pin Diagram:
In this tutorial, I'll show you how to interface an LCD with the PIC16C77 microcontroller.
Components Used:
1. 16x2 LCD
2. Crystal
3. Capacitors
4. Resistors
Proteus Circuit Diagram:
MikroC Code:
//Code by Shahid Khan
//Interfacing LCD
#define LCD PORTC //LCD is connected to PORTC
sbit RS at PORTD.B0; //RS is connected to pin0 of portD
sbit EN at PORTD.B1; //EN is connected to pin1 of portD
void LCD_CMD(unsigned char x)
{
LCD=x;//send data to LCD
RS=0;
EN=1;
Delay_ms(2);
EN=0;
}
void LCD_DATA(unsigned char y)
{
LCD=Y; //send data to LCD
RS=1;
EN=1;
Delay_ms(2);
EN=0;
}
void LCD_STRING(unsigned char *Str) //send string function
{
while(*Str)//stay in this loop while data is not finshed
LCD_DATA(*Str++);//send one by one data to LCD
}
void LCD_INI()
{
Delay_ms(300);
LCD_CMD(0x38);//set 8 bit LCD mode, 2 line and 5x10 dots
LCD_CMD(0x0E);//Cursor OFF
LCD_CMD(0x01);//clear LCD
}
void main() {
TRISC = 0;//C Port output
TRISD.RD0 = 0; //D0 Pin output
TRISD.RD1 = 0; //D1 Pin output
LCD_INI();
Delay_ms(300);
LCD_STRING("Hello Wingineers!"); //Write to LCD
}
Proteus Simulation Video:

No comments

Powered by Blogger.