Created
October 22, 2019 21:04
-
-
Save d-boz-wtwh/3d65d7f0cf989e1929ef04e59d4d89ec to your computer and use it in GitHub Desktop.
Microcontroller Projects
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
#include <htc.h> | |
#define _XTAL_FREQ 20000000 | |
void delay(unsigned int time) //Time delay function | |
{ | |
unsigned int i,j; | |
for(i=0;i< time;i++) | |
for(j=0;j<5;j++); | |
} | |
//Function for sending values to the command register of LCD | |
void lcdcmd(unsigned char value) | |
{ | |
PORTB=value; | |
RD6= 0; //register select-rs | |
RD5 = 0; //read-write-rw | |
RD7 = 1; //enable-e | |
delay(50); | |
RD7=0; //enable-e | |
delay(50); | |
} | |
//Function for sending values to the data register of LCD | |
void display(unsigned char value) | |
{ | |
PORTB=value; | |
RD6= 1; //register select-rs | |
RD5= 0; //read-write-rd | |
RD7= 1; //enable-e | |
delay(500); | |
RD7=0; //enable-e | |
delay(50); | |
} | |
//function to initialize the registers and pins of LCD | |
//always use with every lcd of hitachi | |
void lcdint(void) | |
{ | |
TRISB=0x00; //PortB is used as output port | |
TRISD5=0; | |
TRISD6=0; | |
TRISD7=0; | |
delay(15000);display(0x30);delay(4500);display(0x30);delay(300);display(0x30);delay(650); | |
lcdcmd(0x38); //Character font made is 5x7 matrix | |
delay(50); | |
lcdcmd(0x0C); | |
delay(50); | |
lcdcmd(0x01); | |
delay(50); | |
lcdcmd(0x06); | |
delay(50); | |
lcdcmd(0x80); //Selects 16x2 lcd coulomb 1 row 1 | |
delay(50); | |
} | |
void main() | |
{ | |
char a,b,c,d; | |
unsigned int i; | |
lcdint(); | |
while(1){ | |
c=0x80;d=0xC0; //Lcd Commands | |
a='A';b='a'; | |
i=0; | |
lcdcmd(0x01); //Clear lcd Command | |
while(i!=24){ | |
lcdcmd(c); | |
display(a); //Displaying upper case letters | |
a++; | |
c++; | |
lcdcmd(d); | |
display(b); //Displaying lower case letters | |
b++; | |
d++; | |
i++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment