哪位高手请帮我看看,我这个是针对自己
单片机,P2^6口接RS, P2^5
口接WR,P2^7口接E,但是程序编译没错误,下载到
单片机后液晶屏没有显示是为什么呢?
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="I LOVE MCU!";
uchar code table1[]="WWW.TXMCU.COM";
sbit lcdrs=P2^6;
sbit lcden=P2^7;
sbit lcdrw=P2^5;
uchar num;
void delay(uint z)
{
uint x,y;
for (x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
lcdrs=0; lcdrw=0;lcden=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar date)
{
lcdrs=1;
lcdrw=0;
lcden=0;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
lcden=0;
write_com(0x38);
delay(1);
write_com(0xc0);
delay(1);
write_com(0x06); delay(1);
write_com(0x01);delay(1);
}
void main()
{
init();
write_com(0x80);
for (num=0;num<11;num++)
{
write_data(table[num]);
delay(5) ;
}
write_com(0x80+0x40);
for (num=0;num<13;num++)
{ write_data(table1[num]);
delay(5);
}
while(1);
}
- #include <reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar code table[]="I LOVE MCU!";
- uchar code table1[]="WWW.TXMCU.COM";
- sbit lcdrs=P2^6;
- sbit lcden=P2^7;
- sbit lcdrw=P2^5;
- uchar num;
- void delay(uint z)
- {
- uint x,y;
- for (x=z;x>0;x--)
- for(y=110;y>0;y--);
- }
- void write_com(uchar com)
- {
- lcdrs=0;
- P0=com;
- delay(5);
- lcden=1;
- delay(5);
- lcden=0;
- }
- void write_data(uchar date)
- {
- lcdrs=1;
- P0=date;
- delay(5);
- lcden=1;
- delay(5);
- lcden=0;
- }
- void init()
- {
- lcden=0;
- lcdrw=0;
- write_com(0x38);delay(1);
- write_com(0x0e);delay(1);
- write_com(0x06);delay(1);
- write_com(0x01);delay(1);
- }
- void main()
- {
- init();
- write_com(0x80);
- for (num=0;num<11;num++)
- {
- write_data(table[num]);
- delay(20) ;
- }
- write_com(0x80+0x40);
- for (num=0;num<13;num++)
- { write_data(table1[num]);
- delay(5);
- }
- while(1);
- }
复制代码参考郭天祥的那个代码改的,看看能不能运行吧
一周热门 更多>