Monday, 19 October 2015

PIC16F877A 8BIT LCD OPERATE BY SWITCH



#include<pic.h>
#include<htc.h>
#define __PIC16F877A_H
__CONFIG(WDTE_OFF & FOSC_HS & PWRTE_OFF & LVP_OFF & BOREN_OFF);
unsigned char x=0,*arr[]={"SUMMIT BHARDWAJ","GREATER NOIDA"};
void delay(unsigned int i)
{
while(i--);
}
void cmd(unsigned char c)
{
PORTD=c;
PORTC=0x04;
delay(100);
PORTC=0x00;
}
void dat(unsigned char c)
{
PORTD=c;
PORTC=0x05;
delay(100);
PORTC=0x01;
}
void lcd_init()
{
cmd(0x01);
delay(100);
cmd(0x0e);
delay(100);
cmd(0x80);
delay(100);
cmd(0x38);
delay(100);
}
void string(unsigned char *p)
{
while(*p!='\0')
{
dat(*p);
p++;
}
}

int main()
{
TRISAbits.TRISA1=0;// define PORTA bitb 1 as output pin
PORTAbits.RA1=1; // give the value to porta
TRISC=0x00;
TRISD=0X00;
lcd_init();
ADCON1=0X06;   // make all analog pins as Digital pins
while(1)
{
for(x=0;x<2;x++)
{
while(PORTAbits.RA1==1);
string (arr[x]);
cmd(0x80);
while(PORTAbits.RA1==0);

}
}
}

No comments:

Post a Comment