RS,RW电压正常,
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar a;
sbit RS=P2^5; //寄存器选择位
sbit RW=P2^6; //读写选择位
sbit E=P2^7; //使能信号位
const uchar star[]={"wellcome"};
xdata uchar star3[]={"up"};
xdata uchar star4[]={"down"};
xdata uchar star5[]={"CCCCC"};
void delay(uchar x)
{
uchar i;
while(x--)
{
for(i=0;i<255;i++);
}
}
void WriteInstruction(uchar dictate)
{
RS=0;
RW=0;
E=0;
P0=dictate;
delay(1);
E=1;
_nop_();
_nop_();
_nop_();
_nop_();
E=0;
}
//*********************写数据
void WriteData(uchar dat)
{
RS=1;
RW=0;
E=0;
P0=dat;
delay(1);
E=1;
_nop_();
_nop_();
_nop_();
_nop_();
E=0;
}
//*******************初始化
void Init(void)
{
WriteInstruction(0x38); //显示模式设置:16×2显示,5×7点阵,8位数据接口
WriteInstruction(0x0c); //显示模式设置:显示开,无光标
WriteInstruction(0x06); //显示模式设置:光标右移,字符不移
WriteInstruction(0x01); //清屏幕指令,将以前的显示内容清除
}
/////////////////////////////////////////////////////////////////////////////////////
void main()
{
Init();
while(1)
{
a=0;
WriteInstruction(0x80);
while(star[a]!='\0')
{
WriteData(star[a]); a++;
delay(80);
}
delay(200);delay(200);
a=0;
WriteInstruction(0x80);
while(star[a]!='\0')
{
WriteData(0x20); a++;
delay(50);
}
a=0;
WriteInstruction(0x80);
while(star3[a]!='\0')
{
WriteData(star3[a]); a++;
delay(50);
}
a=0;
WriteInstruction(0xc0);
while(star4[a]!='\0')
{
WriteData(star4[a]); a++;
delay(50);
}
a=0;
delay(200);delay(200);delay(200);
WriteInstruction(0x01);
WriteInstruction(0x80);
while(star5[a]!='\0')
{
WriteData(star5[a]); a++;
delay(50);
}
delay(200);delay(200);delay(200);
WriteInstruction(0x01);
}
}