网上抄的代码,有大手子帮忙简单注释一下嘛,秋梨膏
#include<reg52.h>
typedef unsigned char uchar;
typedef unsigned int uint;
#define led P1
sbit voice=P2^0;
uchar code tab1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//从上到下
uchar code tab2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//从下到上
uchar code tab3[]={0xe7,0xdb,0xbd,0x7e};//从中间到两边
uchar code tab4[]={0x7e,0xbd,0xdb,0xe7};//从两边到中间
uchar he[4]={0,0,0,0};
uchar num=0;
uchar counter=0;//定时计数
uchar counter1=0;//定时计数
bit flag=0;//切换闪烁
bit flag1=0;
void delay1m(uint x)
{
uint i,j;
for(i=0;i<x;i++)//连数数次
for(j=0;j<120;j++); //连数120次,约1ms
}
void time0_time1_init()
{
TMOD=0x11;
TH1=(65535-50000)/256;TL1=(65535-50000)%256;
TH0=(65535-50000)/256;TL0=(65535-50000)%256;
TR0=0;ET1=ET0=TR1=EA=1;
}
void main()
{
time0_time1_init();delay1m(2000);
while(1)
{
if(!flag1)
{
if(!voice)
{
num++;flag1=1;
he[0]=he[1]=he[2]=he[3]=0;
if(num>=5){num=0;}
TR0=1;
}
}
}
}
void time1_interrupt()interrupt 3
{
TH1=(65535-50000)/256;TL1=(65535-50000)%256;
counter++;
if(counter>=6)
{
counter=0;
switch(num)
{
case 0:if(flag==0){led=0x00;flag=1;}else {led=0xff;flag=0;}break;
case 1:led=tab1[he[0]];he[0]++;if(he[0]>=8)he[0]=0;break;
case 2:led=tab2[he[1]];he[1]++;if(he[1]>=8)he[1]=0;break;
case 3:led=tab3[he[2]];he[2]++;if(he[2]>=4)he[2]=0;break;
case 4:led=tab4[he[3]];he[3]++;if(he[3]>=4)he[3]=0;break;
default:break;
}
}
}
void time0_interrupt()interrupt 1
{
TH0=(65535-50000)/256;TL0=(65535-50000)%256;
counter1++;
if(counter1>=20)//1s后再检测
counter1=0;
flag1=0;
TR0=0;
}
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。
因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。