世上最簡(jiǎn)單的遙控(數(shù)碼管顯示)電子鐘(C語(yǔ)言編寫)
//==============================================================
main()
{
TMOD=0x11;
EA=1;
TR0=1;
ET0=1;
TL0=0;
TH0=0;
TR1=1;
ET1=1;
TH1=(65536-100)/256; //定時(shí)器0設(shè)定約1000us中斷一次,用于數(shù)碼管掃描
TL1=(65536-100)%256;
while(1)
{
yin();
switch(IRBUF[2])
{
case 0x58:flash=~flash;if(flash==0)power=0;//進(jìn)入調(diào)整時(shí)間狀態(tài)
break;
case 0x1b:if(flash==1){shij++;if(shij>23)shij=0;}//如果數(shù)碼管在閃爍則可以進(jìn)入小時(shí)"+"調(diào)整
break;
case 0x1f:if(flash==1){shij--;if(shij<=(0-1))shij=23;}//如果數(shù)碼管在閃爍則可以進(jìn)入小時(shí)"-"調(diào)整
break;
case 0x0f:if(flash==1){fen++;if(fen>59)fen=0;}//如果數(shù)碼管在閃爍則可以進(jìn)入分"+"調(diào)整
break;
case 0x1a:if(flash==1){fen--;if(fen<=(0-1))fen=59;}//如果數(shù)碼管在閃爍則可以進(jìn)入分"-"調(diào)整
break;
}
}
}
void zhong3() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
num++;
ding++;
if(num>=10)
{
num=0;
miao++;//數(shù)碼管閃爍變量
if(flash==0)
flag=~flag;
else
flag=0;
if(miao>119)
{
miao=0;
fen++;
if(fen>59)
{
fen=0;
shij++;
if(shij>23)
shij=0;
}
}
}
}
void zhong1() interrupt 1
{
TL0=0;
TH0=0;
}
評(píng)論