硬件连接图与效果见附件
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar i,j,m,k;
void Display();
uchar code tab1[]={ 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar code tab2[][8]={
{0xff,0xff,0x83,0xab,0x83,0xab,0x83,0xff},//田
{0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xc3},//L
{0xff,0xc3,0xbd,0xbd,0xbd,0xbd,0xc3,0xff},//O
{0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xd7,0xef},//V
{0xff,0x83,0xfb,0xfb,0x83,0xfb,0xfb,0x83},//E
{0xff,0x01,0xff,0x11,0x11,0x55,0x55,0xff},//丽
{0xff,0xc9,0xb6,0xbe,0xdd,0xeb,0xf7,0xff},//"心"
};
void delay1(uint cn)
{
while(--cn);
}
main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
ET0=1;
EA=1;
while(1)
{
Display();
}
}
void time0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
k++;
if(k==20)
{
k=0;
j++;
}
}
void Display()
{
while(j<7)
{
for(i=0;i<8;i++)
{
P0=tab1[i];
P2=tab2[j][i];
delay1(50);
P2=0xff;
}
}
j=0;
P2=0xff;
P0=0xff;
} |