您的位置 首页 ADAS

根据C8051f020吴伟镖动画LCD操控显现

includec8051f020h>defineucharunsignedchardefineuintunsignedintvoidSYSCLK_Init(void);voidPORT_Init

#include

#define uchar unsigned char
#define uint unsigned int
void SYSCLK_Init (void);
void PORT_Init (void);
sbit lcdrs=P2^5;
sbit lcden=P2^7;
sbit lcdwr=P2^6;
sbit key1=P2^0;
sbit key2=P2^1;
sbit key3=P2^2;
sbit key4=P2^3;
unsigned long x;
uchar CGCODE[]={0x1f,0x11,0x1f,0x00,0x1f,0x04,0x1f,0x0a, //0
0x01,0x02,0x06,0x0a,0x02,0x02,0x02,0x02, //1
0x04,0x01f,0x04,0x1f,0x04,0x1f,0x05,0x04, //2
0x04,0x04,0x04,0x1f,0x0e,0x15,0x04,0x04, //3
0x00,0x0e,0x00,0x1f,0x0e,0x15,0x0c,0x04, //4
0x08,0x0c,0x0a,0x09,0x19,0x05,0x03,0x01, //球门 5
0x04,0x0a,0x0a,0x04,0x0e,0x04,0x0a,0x00,//人 6
0x00,0x00,0x00,0x00,0x6,0x09,0x09,0x06,//球 7
};
uchar tab[]={0x00,0x01,0x02,0x03,0x04, , , , , };
uchar abc[]={0x32,0x30,0x31,0x31,0x31,0x31,0x38,0x34,0x31,0x32,0x32};
uchar ren[]={0x06, , , , , , , , , , , ,0x05, , };
uchar qiu[]={0x6f, };
uchar zhuhe[]={0x47,0x4f,0x4f,0x44,0x21, };
void delay(void)
{
int a=10000;
while(a!=0)
{
a–;
}
}
void write_com(uchar com)
{
lcdrs=0;
P3=com;
delay();
lcden=1;
delay();
lcden=0;
}
void write_date(uchar dat)
{
lcdrs=1;
P3=dat;
delay();
lcden=1;
delay();
lcden=0;
}
void init()
{
lcdwr=0;
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main()
{
uchar data2;
uchar i;
uchar j;
static unsigned char data1;
WDTCN = 0xde;
WDTCN = 0xad;
SYSCLK_Init ();
PORT_Init ();
init();
lcdrs=0;
lcdwr=0;
write_com(0x40);
for(i=0;i<56;i++)
{
write_date(CGCODE[i]);
}
write_com(0x80);
for(i=0;i<9;i++)
{
write_date(tab[i]);
}
write_com(0x80+0x40);
for(i=0;i<12;i++)
{
write_date(abc[i]);
}
while(1)
{
if(key1==0)
{
key1=1;
delay();
if(key1==0)
{
while(key1==0);
write_com(0x01);
}
}
if(key2==0)
{
key2=1;
delay();
if(key2==0)
{
while(key2==0);
for(j=0;j<=1;j++) //移位16x2循环
{
write_com(0x18); //移位
delay();
}
}
}
if(key4==0)
{ write_com(0x01);
key4=1;
delay();
if(key4==0)
{
while(key4==0);
{ write_com(0x80);
for(i=0;i<9;i++)
{
write_date(tab[i]);
}
write_com(0x80+0x40);
for(i=0;i<12;i++)
{
write_date(abc[i]);
}
} }
}
if(key3==0)
{
key3=1;
delay();
if(key3==0)
{
while(key3==0);
write_com(0x01);
write_com(0x80);
for(i=0;i<=16;i++)
{
write_date(ren[i]);
}
for(j=1;j<=9;j++)
{write_com(0x80+0x01+j) ;
for(i=0;i<=1;i++)
{write_date(qiu[i]);
write_com(0x80+0x01+j-1) ;
write_date(0xfe);}
delay();
if(j==9)
{write_com(0x01);
write_com(0x80+0x06);
for(i=0;i<=5;i++)
write_date(zhuhe[i]);
}}
}
}
}
}
void SYSCLK_Init (void)
{
OSCICN = 0x05;
}
void PORT_Init (void)
{
XBR0 = 0x00;
XBR2 = 0x40;
P2MDOUT = 0xe0;
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/adas/317867.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部