大伙帮我看看这个程序搞进去 硬件不良的原因,编译无错误。
#include<reg51.h>#define uint unsigned int
#define uchar unsigned char
uchar code table[]="I LOVE YOU" ;
uchar code table1[]="FREE LOVE LIFE";
sbit lcd_e=P2^4; 、?//定义端口
sbit lcd_rs=P2^6;
uint q,p;
uchar num;
void delay(q)
{
while(q)
{
for(p=100;p>0;p--);
q--;
}
} //延时
void write_com(uchar com)
{
lcd_rs=0;
P1=com;
delay(10);
lcd_e=1;
delay(10);
lcd_e=0;
delay(10);
} 、//写命令
void write_date(uchar date)
{
lcd_rs=1;
P1=date;
delay(10);
lcd_e=1;
delay(10);
lcd_e=0;
delay(10);
} //写数据
void initalize()
{
lcd_e=0;
write_com(0X38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
} //初始化
void main()
{
initalize();
write_com(0x80);
for(num=0;num<10;num++)
{
write_date(table[num]);
delay(10);
}
write_com(0x80+0x40);
for(num=0;num<14;num++)
{
write_date(table[num]);
delay(1);
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
应该是硬件的问题,换了液晶好了。谢了!
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit EN=P2^7; //位声明
sbit RS=P2^5;
sbit RW=P2^6;
uchar code table[]="WWW.CQRYKJ.COM"; //显示数据库
uchar code table1[]="2012.11.02";
uchar num;
void delay(uint z) //延时函数
{
uint x,y;
for(x=110;x>0;x--)
for(y=z;y>0;y--);
}
void write_com(uchar com)
{
RS=0;
P3=com;
delay(5);
EN=1;
delay(5);
EN=0;
}
void write_data(uchar date)
{
RS=1;
P3=date;
delay(5);
EN=1;
delay(5);
EN=0;
}
void init()
{
EN=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
//write_com(0x80+0x10);
}
void main()
{
init();
// write_data('1');
while(1);
for(num=0;num<14;num++)
{
write_data(table[num]);
delay(20);
}
write_com(0x80+0x40);
for(num=0;num<10;num++)
{
write_data(table1[num]);
delay(20);
}
}
一周热门 更多>