Check out this great project from electrosome: https://electrosome.com/lcd-pic-mplab-xc8/
PIC16F877A, 5V power, XC8 compiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* File: newmain.c | |
* Code modified from | |
* https://electrosome.com/lcd-pic-mplab-xc8/ | |
* This is for a PIC16F877A; 5V PS; XC8 compiler | |
* Created on February 12, 2017, 4:52 PM | |
*/ | |
#define _XTAL_FREQ 8000000 | |
#define RS RD2 | |
#define EN RD3 | |
#define D4 RD4 | |
#define D5 RD5 | |
#define D6 RD6 | |
#define D7 RD7 | |
#include <xc.h> | |
#include "lcd.h"; | |
// 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 | |
int main() | |
{ | |
unsigned int a; | |
TRISD = 0x00; | |
Lcd_Init(); | |
while(1) | |
{ | |
Lcd_Clear(); | |
Lcd_Set_Cursor(1,1); | |
Lcd_Write_String("Hi i love you"); | |
Lcd_Set_Cursor(2,1); | |
Lcd_Write_String("AUTUMN"); | |
__delay_ms(2000); | |
Lcd_Clear(); | |
Lcd_Set_Cursor(1,1); | |
Lcd_Write_String("A message from:"); | |
Lcd_Set_Cursor(2,1); | |
Lcd_Write_String("2020-06-27"); | |
__delay_ms(2000); | |
Lcd_Clear(); | |
Lcd_Set_Cursor(1,1); | |
Lcd_Write_String("Hello There!"); | |
Lcd_Set_Cursor(2,1); | |
Lcd_Write_String("I am a computer!"); | |
//for(a=0;a<15;a++) | |
//{ | |
// __delay_ms(300); | |
// Lcd_Shift_Left(); | |
//} | |
//for(a=0;a<15;a++) | |
//{ | |
// __delay_ms(300); | |
// Lcd_Shift_Right(); | |
//} | |
__delay_ms(2000); | |
Lcd_Clear(); | |
Lcd_Set_Cursor(1,1); | |
Lcd_Write_String("I love you!"); | |
Lcd_Set_Cursor(2,1); | |
Lcd_Write_String("Freckles is whiny!"); | |
__delay_ms(2000); | |
Lcd_Clear(); | |
Lcd_Set_Cursor(1,1); | |
Lcd_Write_String("Abby is FUZZY!"); | |
//for(a=0;a<15;a++) | |
//{ | |
// __delay_ms(300); | |
// Lcd_Shift_Left(); | |
//} | |
//for(a=0;a<15;a++) | |
//{ | |
// __delay_ms(300); | |
// Lcd_Shift_Right(); | |
//} | |
//Lcd_Clear(); | |
//Lcd_Set_Cursor(2,1); | |
//Lcd_Write_Char('e'); | |
//Lcd_Write_Char('S'); | |
__delay_ms(2000); | |
} | |
return 0; | |
} |