#include "16F877a.h"
#fuses HS // High speed crystal
#use delay(clock=16000000)
#define RS PIN_B2
#define EN PIN_B0
void lcd_init();
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
unsigned int16 i;
void main()
{
output_low(PIN_B1);
lcd_init();
delay_ms(100);
for(i=1;i<=50;i++)
{
output_c(0b00100000);
delay_ms(100);
output_c(0b00010000);
delay_ms(100);
output_c(0b00001000);
delay_ms(100);
output_c(0b00000100);
delay_ms(100);
}
}
void lcd_init()
{
lcd_cmd(0x38); // Configure the LCD in 8-bit mode, 2 line and 5x7 font
lcd_cmd(0x0c); // display on and cursor off
lcd_cmd(0x01); // clear display screen
lcd_cmd(0x06); // increment cursor
lcd_cmd(0x80); // set cursor to 1st line
}
void lcd_cmd(unsigned char c)
{
output_b(c);
output_low(RS);
output_high(EN);
delay_ms(15);
output_low(EN);
}
void lcd_data(unsigned char z)
{
output_b(z);
output_high(RS);
output_high(EN);
delay_ms(15);
output_low(EN);
}