How to interface a 16*4 LCD with PIC18F452 with codes


Over the past week I am puzzled that how to interface a lcd with pic18f452 microcontroller atlast i got it working

Softwares Used

1. mikroc for pic pro
2. proteus vsm simulator (demo version)

Hardwares Used

1. 16*4 LCD
2. PIC18F452
3. 8Mhz Crystal Oscillator
4. and resistors, capacitors, power supply etc.

The Following is the schematic


The Following is the working code


LCD
sbit Lcd_RS at RA0_bit;
sbit Lcd_EN at RA2_bit;
sbit Lcd_D7 at RB7_bit;
sbit Lcd_D6 at RB6_bit;
sbit Lcd_D5 at RB5_bit;
sbit Lcd_D4 at RB4_bit;
sbit Lcd_D3 at RB3_bit;
sbit Lcd_D2 at RB2_bit;
sbit Lcd_D1 at RB1_bit;
sbit Lcd_D0 at RB0_bit;
sbit Lcd_RS_Direction at TRISA0_bit;
sbit Lcd_EN_Direction at TRISA2_bit;
sbit Lcd_D7_Direction at TRISB7_bit;
sbit Lcd_D6_Direction at TRISB6_bit;
sbit Lcd_D5_Direction at TRISB5_bit;
sbit Lcd_D4_Direction at TRISB4_bit;
sbit Lcd_D3_Direction at TRISB3_bit;
sbit Lcd_D2_Direction at TRISB2_bit;
sbit Lcd_D1_Direction at TRISB1_bit;
sbit Lcd_D0_Direction at TRISB0_bit;
// End Lcd8 module connections

char * text;

void main(){
    ADCON1 |= 0x07;
    TRISA = 0;
    INTCON = 0;
    INTCON1 = 0;
    INTCON2 = 0;
    CCP2CON = 0;
    TRISB=0;
    Delay_ms(2000);
Lcd_Init();
Delay_ms(2000);
Lcd_Cmd(_Lcd_CLEAR);
//Lcd_Cmd(_Lcd_CURSOR_OFF);
Delay_ms(2000);
text = "WWW.ANDRIL.IN"    ;
Lcd_Out(1,1,text);
Delay_ms(2000);
text = "BLOG.KATHIR.CO.IN"    ;
Lcd_Out(1,1,text);
    }

The above code works only when lcd library in mikroc is enabled
it works only with mikroc
/ Test these codes at your own risk. we are not responsible for any malfunctions/


Share on Google Plus

About Kathiravan

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment