Interfacing 16X4 LCD
Simulation is done with Proteus ISIScode: MikroC
Requirements:
- 16X4 LCD
- PIC16F877A
- 8 MHz oscillator
- A variable resistor (5k)
- 22pF capacitor
- A resistor (10k)
Circuit Diagram of 16X4 LCD and code is shown below
// Begin LCD configuration
sbit LCD_RS_direction at TRISB0_bit;
sbit LCD_EN_direction at TRISB1_bit;
sbit LCD_D4_direction at TRISB2_bit;
sbit LCD_D5_direction at TRISB3_bit;
sbit LCD_D6_direction at TRISB4_bit;
sbit LCD_D7_direction at TRISB5_bit;
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
// End of LCD configuration
void main()
{ char txt1[]="welcome to 16x4"; char txt2[]="LCD display";
char txt3[]="by"; char txt4[]="EKETECH";
TRISB=0X00; // Configure PORTB as output
PORTB=0X00; // initialise PORTB
while(1) // loop
{
lcd_Init(); // initialise LCD
lcd_cmd(_lcd_clear); // clear LCD
lcd_cmd(_lcd_cursor_off); //OFF the cursor
delay_ms(100); // delay for 0.1 second
lcd_out(1,1,txt1); // display "welcome to 16x4" on row 1 of LCD
lcd_out(2,3,txt2); // display "LCD display"; on row 2 column 3
delay_ms(200); // delay for 0.2 second
lcd_out(3,4,txt3); // display "by" on row 3 column 4 of LCD
delay_ms(200); // delay for 0.2 second
lcd_out(4,1,txt4); // display "EKETECH"; on row 4 column 1
delay_ms(1500); // delay for 1.5 seconds
}
}
Click hereVideo
By EKETECH