|
1602的显示程序,为什么我的第一行没有显现,而第二行正常呢?
#include
#define uint unsigned int
#define uchar unsigned char
sbit wei=P2^7;
sbit duan=P2^6;
sbit rs=P3^5;
sbit leden=P3^4;
uchar num;
uchar code table1[]="zhao yao"; //中括号中不可以加参数;
uchar code table2[]="zhao yao";
void init();
void write_data(uchar);
void write_com(uchar);
void delay(uchar z);
void main()
{
init();
for(num=0;num<8;num++)
{
write_data(table1[num]);
delay(10);
}
write_com(0x80+0x40);
for(num=0;num<8;num++)
{
write_data(table2[num]);
delay(10);
}
while(1); //此步切不可少
}
void init()
{
wei=1;
P0=0xff;
wei=0;
duan=1;
P0=0x00;
duan=0;
leden=0;
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x01);//显示清屏
write_com(0x80);//数据指针设置
}
void write_data( uchar date)
{
rs=1;
P0=date;
delay(1);
leden=1;
delay(5);
leden=0;
delay(2);
}
void write_com(uchar com)
{
rs=0;
P0=com;
delay(1);
leden=1;
delay(5);
leden=0;
delay(2);
}
void delay(uchar z)
{
uchar x,y;
for(x=0;x
for(y=0;y<110;y--);
}
|
|