8位串行數(shù)碼管模塊__設(shè)計(jì)原理圖及測(cè)試程序
//按鍵控制//
void bcon(void)
{if(P3_5==0)
{delay(100);
if(P3_5==0)
{second=0;
while(P3_5==0);
}
}
disbuf[0]=second%10;
disbuf[1]=second/10;
if(P3_6==0)
{delay(100);
if(P3_6==0)
{minute++;
while(P3_6==0);
if(minute==60)
{minute=0;
}
}
}
disbuf[3]=minute%10;
disbuf[4]=minute/10;
if(P3_7==0)
{delay(100);
if(P3_7==0)
{hour++;
while(P3_7==0);
if(hour==24)
{hour=0;
}
}
}
disbuf[6]=hour%10;
disbuf[7]=hour/10;
disbuf[0]=second%10;
disbuf[1]=second/10;
disbuf[3]=minute%10;
disbuf[4]=minute/10;
disbuf[6]=hour%10;
disbuf[7]=hour/10;
}
//鍵盤控制//
//主函數(shù)//
void main(void)
{
TMOD=0x02;
TH0=0x06;
TL0=0x06;
TR0=1;
ET0=1;
EA=1;
while(1)
{
bcon();
sdata();
out();
}
while(1);
}
//主函數(shù)//
//中斷程序//
void t0(void) interrupt 1 using 0
{ tcount++;
if(tcount==4000)
{tcount=0;
second++;
if(second==60)
{second=0;
minute++;
if(minute==60)
{minute=0;
hour++;
if(hour==24)
{hour=0;
}
}
}
}
}
//中斷程序//
評(píng)論