#include <REGX51.H>
sbit rs=P2^0;
sbit e=P2^1;
void delay(int n)
{
int i,j;
for(i=0;i<n;i++)
{}
for(j=0;j<1275;j++)
{}
}
void wdata(char a)
{
rs=1;
delay(50);
e=1;
P3=a;
delay(1000);
e=0;
delay(1000);
}
void wcmd(int cmd)
{
rs=0;
delay(1000);
e=1;
P3=cmd;
delay(1000);
e=0;
delay(1000);
}
void intlcd()
{
wcmd(0x38);
delay(10);
wcmd(0x0E);
delay(10);
wcmd(0x01);
delay(10);
wcmd(0x06);
delay(10);
wcmd(0x80);
delay(10);
}
void main()
{
intlcd();
while(1)
{
int z;
char str[]={"hello world"};
wcmd(0x01);
wcmd(0x80);
for(z=0;z<11;z++)
{
wdata(str[z]);
delay(50);
}
}
}
sbit rs=P2^0;
sbit e=P2^1;
void delay(int n)
{
int i,j;
for(i=0;i<n;i++)
{}
for(j=0;j<1275;j++)
{}
}
void wdata(char a)
{
rs=1;
delay(50);
e=1;
P3=a;
delay(1000);
e=0;
delay(1000);
}
void wcmd(int cmd)
{
rs=0;
delay(1000);
e=1;
P3=cmd;
delay(1000);
e=0;
delay(1000);
}
void intlcd()
{
wcmd(0x38);
delay(10);
wcmd(0x0E);
delay(10);
wcmd(0x01);
delay(10);
wcmd(0x06);
delay(10);
wcmd(0x80);
delay(10);
}
void main()
{
intlcd();
while(1)
{
int z;
char str[]={"hello world"};
wcmd(0x01);
wcmd(0x80);
for(z=0;z<11;z++)
{
wdata(str[z]);
delay(50);
}
}
}
No comments:
Post a Comment