新闻中心

EEPW首页>嵌入式系统>设计应用> 89C52单片机之点阵使用

89C52单片机之点阵使用

作者: 时间:2016-11-23 来源:网络 收藏
这次是要通过8*8点阵显示出万代兴三个字,这里每一个汉字的编码都需要自己手写在本子上,然后根据点阵情况写出对应的编码,是个体力活。
程序:
#include
unsigned char code taba[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code tabb[]={0x81,0x41,0x21,0x1f,0x05,0x85,0xfd,0x01,
0x08,0xfc,0x03,0x04,0x1f,0x24,0x45,0xC6, 0x89,0x4a,0x2c,0x0f,0x2c,0x4a,0x89,0x00,0xff,0x00,
0xff,0x00,0xff};
void delay(unsigned char dly)
{
unsigned char i,j;
for(i=100;i>0;i--)
for(j=dly;j>0;j--)
;
}
void main()
{
int cnt,t=0,cnt1=0,tmp=0;
while(1)
{
P0=0xff;
cnt=0;
while(cnt<8)
{
P2=taba[cnt];
if(t>=8&&tmp<8)
P0=0x00;
else
{
if(tmp<8)
P0=tabb[t];
else
{
if(t>=16&&tmp<16)
P0=0x00;
else
{
if(tmp>23)
P0=tabb[tmp+1];
else
{
if(tmp<16)
P0=tabb[t];
else
{
if(t>=24)
P0=0x00;
else
P0=tabb[t];
}
}
}
}
}
t++;
cnt++;
delay(1);
}
cnt1++;
if(cnt1==50)
{
cnt1=0;
tmp++;
if(tmp==28)
tmp=0;
}
t=tmp;
}
}



评论


技术专区

关闭