题目:在lcd1602显示屏上显示出ILIKEMCU!XIAOWU且显示方式为从右边屏依次向左动态移出
标题:在lcd1602显现屏上显现出
“I LIKE MCU!
XIAO WU ”
且显现方法为从右边屏顺次向左动态移出。
解决方案:(c言语编程)
#include
#define uchar unsigned char
#define uint unsigned int
uchar code table[]=”I LIKE MCU!”;
uchar code table1[]=”XIAO WU” ;
sbit lcdrs=P1^7;
sbit lcdrw=P1^6;
sbit lcde=P2^4;
sbit le=P3^6;
sbit leden=P2^5;
sbit dkle=P3^7;
void delay(uint a) ;
uchar num;
void write_com(uchar com) //写入指令子函数
{
lcde=0;
lcdrw=0;
lcdrs=0;
delay(1);
lcde=1;
delay(1);
P0=com;
delay(1);
lcde=0;
}
void write_data(uchar dat) //写入数据子函数
{
lcde=0;
lcdrw=0;
lcdrs=1;
delay(1);
lcde=1;
delay(1);
P0=dat;
delay(1);
lcde=0;
}
void init() //初始化子函数
{
lcde=0;
le=0;
leden=0;
write_com(0x38);
write_com(0x0f);
write_com(0x01);
write_com(0x80+0x10);
}
void main() //主函数
{
init();
for(num=0;num<11;num++) //写入榜首行
{
write_data(table[num]);
delay(1);
}
write_com(0x80+0x40+4+0x10);
for(num=0;num<7;num++)//写入第二行
{
write_data(table1[num]);
delay(1);
}
for(num=0;num<16;num++) //向左动态左移
{
write_com(0x18);
delay(10);
}
while(1) ;
}
void delay(uint a) { //延时函数
uint i,j;
for(j=a;j>0;j–)
for(i=2500;i>0;i–) ;
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/biancheng/260999.html