用单片机控制8*8 Led点阵显示图案
#include <reg51.H>
sbit P20=P2^0;
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code
graph[3][8]={{0x12,0x14,0x3c,0x48,0x3c,0x14,0x12,0x00},
{0x00,0x00,0x38,0x44,0x44,0x44,0x38,0x00},
{0x30,0x48,0x44,0x22,0x44,0x48,0x30,0x00}
};
unsigned char count;
unsigned char cnta;
void main(void)
{
unsigned char i,j;
TMOD=0x01;
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
TR0=1;
ET0=1;
EA=1;
while(1)
{
if(P20==0)
{
for(i=5;i>0;i--)
for(j=248;j>0;j--);
if(P20==0)
{
count++;
if(count==3)
{
count=0;
}
while(P20==0);
}
}
}
}
void t0(void) interrupt 1 using 0
{
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
P3=tab[cnta];
P1=graph[count][cnta];
cnta++;
if(cnta==8)
{
cnta=0;
}
}
完整资料打包(含仿真):