#define _XTAL_FREQ 20000000 #define RS RD2 #define EN RD3 #define D4 RD4 #define D5 RD5 #define D6 RD6 #define D7 RD7 #include // BEGIN CONFIG #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled) #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off) #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) //END CONFIG //LCD Functions Developed by electroSome //Code modified by Zaye_Labz void Lcd_Port(char a) { if(a & 1) D4 = 1; else D4 = 0; if(a & 2) D5 = 1; else D5 = 0; if(a & 4) D6 = 1; else D6 = 0; if(a & 8) D7 = 1; else D7 = 0; } void Lcd_Cmd(char a) { RS = 0; // => RS = 0 Lcd_Port(a); EN = 1; // => E = 1 __delay_ms(4); EN = 0; // => E = 0 } Lcd_Clear() { Lcd_Cmd(0); Lcd_Cmd(1); } void Lcd_Set_Cursor(char a, char b) { char temp,z,y; if(a == 1) { temp = 0x80 + b - 1; z = temp>>4; y = temp & 0x0F; Lcd_Cmd(z); Lcd_Cmd(y); } else if(a == 2) { temp = 0xC0 + b - 1; z = temp>>4; y = temp & 0x0F; Lcd_Cmd(z); Lcd_Cmd(y); } } void Lcd_Init() { Lcd_Port(0x00); __delay_ms(20); Lcd_Cmd(0x03); __delay_ms(5); Lcd_Cmd(0x03); __delay_ms(11); Lcd_Cmd(0x03); ///////////////////////////////////////////////////// Lcd_Cmd(0x02); Lcd_Cmd(0x02); Lcd_Cmd(0x08); Lcd_Cmd(0x00); Lcd_Cmd(0x0C); Lcd_Cmd(0x00); Lcd_Cmd(0x06); } void Lcd_Write_Char(char a) { char temp,y; temp = a&0x0F; y = a&0xF0; RS = 1; // => RS = 1 Lcd_Port(y>>4); //Data transfer EN = 1; __delay_us(40); EN = 0; Lcd_Port(temp); EN = 1; __delay_us(40); EN = 0; } void Lcd_Write_String(char *a) { int i; for(i=0;a[i]!='\0';i++) Lcd_Write_Char(a[i]); } //void Lcd_Shift_Right() //{ // Lcd_Cmd(0x01); // Lcd_Cmd(0x0C); //} void Lcd_Shift_Left() { Lcd_Cmd(0x01); Lcd_Cmd(0x08); } int main() { unsigned int a; TRISD = 0x00; Lcd_Init(); while(1) { Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String("Home Amplifier"); Lcd_Set_Cursor(2,1); Lcd_Write_String(" Designed by "); __delay_ms(3500); Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String("Zaye_Labz"); Lcd_Set_Cursor(2,1); Lcd_Write_String("0813764xxxx"); __delay_ms(3500); Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String("visit www.zayelectronics.com"); for(a=0;a<15;a++) { __delay_ms(800); Lcd_Shift_Left(); } //for(a=0;a<15;a++) //{ // __delay_ms(300); // Lcd_Shift_Right(); //} Lcd_Clear(); Lcd_Set_Cursor(2,1); Lcd_Write_String("Thank"); Lcd_Write_String("You"); __delay_ms(2000); } return 0; }