Created
October 22, 2019 21:04
-
-
Save d-boz-wtwh/7c723c695e252dbacc1ae6a4ed3f8b86 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<reg52.h> | |
sbit rs=P3^5; | |
sbit rw=P3^6; | |
sbit en=P3^7; | |
void delay() | |
{ | |
unsigned int i,j; | |
for(i=0;i<700;i++) | |
for(j=0;j<10;j++); | |
} | |
void command(unsigned int comand) // Writing commands to lcd | |
{ | |
P1=comand; rw=0; rs=0; en=0; | |
delay(); | |
en=1; | |
delay(); | |
en=0; | |
} | |
void lcddata(char value) //Writing data to lcd | |
{ | |
P1=value; rw=0; rs=1; en=0; | |
delay(); | |
en=1; | |
delay(); | |
en=0; | |
} | |
void lcd() //Function to initialize lcd | |
{ | |
P1=0x00; //Port-1 as Output | |
P3=0x00; //Port-3 as Output | |
delay(); command(0x30); delay(); command(0x30); delay(); command(0x30); | |
delay(); command(0x38); delay(); command(0x01); delay(); command(0x0F); | |
delay(); command(0x0C); delay(); command(0x80); delay(); | |
} | |
void main() | |
{ | |
char a,b,c,d; | |
unsigned int i; | |
lcd(); | |
while(1){ | |
c=0x80;d=0xC0; //Lcd Commands | |
a='A';b='a'; | |
i=0; | |
command(0x01); //Clear lcd Command | |
while(i!=24){ | |
command(c); | |
lcddata(a); //Displaying upper case letters | |
a++; | |
c++; | |
command(d); | |
lcddata(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