#include<reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit e=P1^2;
sbit rs=P1^4;
sbit rw=P1^3;
sbit psb=P1^5;
void xianshi(void);
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
rw=0;
rs=0;
delay(2) ;
P2=com;
e=1;
delay(10);
e=0;;;
delay(3) ;
}
void write_data(uchar date)
rw=0;
rs=1;
delay(2) ;
P2=date;
e=1;
delay(10);
e=0;;;
delay(3) ;
}
void init()
{
delay(3);
write_com(0x30);
delay(5);
write_com(0x30);
delay(5);
write_com(0x0f);
delay(4);
write_com(0x01);
delay(240);
write_com(0x06);
delay(10);
}
void main()
{
init();
while(1);
{
xianshi();
while(1);
}
}
void xianshi(void)
{
uchar i;
uchar a;
a=0x10;
write_com(0x80);
delay(2);
for (i=0;i<16;i++)
{
write_com(a);
delay(2);
a++;
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>