#include<reg51.h> #include<intrins.h> #define uchar unsigned char
intert(); show(); flicker(); timeshow(); delays(uchar i);
uchar second,minute,hour,i,j,n,k;
uchar Timetable[6]; uchar Ledtable[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
main() { intert();
while(1) { show(); flicker(); } }
show() { timeshow(); P2=0xfe; for(n=0;n<6;n++) { P0=Ledtable[Timetable[n]]; if(n==2)P0=P0|0x80; if(n==4)P0=P0|0x80; delays(1); P2=_crol_(P2,1); } }
timeshow() { Timetable[0]=second%10; Timetable[1]=second/10; Timetable[2]=minute%10; Timetable[3]=minute/10; Timetable[4]=hour%10; Timetable[5]=hour/10; }
flicker() { while(k==1) { for(i=0;i<150;i++) { P2=0xfb; for(n=2;n<6;n++) { P0=Ledtable[Timetable[n]]; if(n==2)P0=P0|0x80; if(n==4)P0=P0|0x80; delays(1); P2=_crol_(P2,1); } } for(i=0;i<170;i++) { show(); } }
while(k==2) { for(i=0;i<150;i++) { P2=0xfe; for(n=0;n<2;n++) { P0=Ledtable[Timetable[n]]; if(n==2)P0=P0|0x80; if(n==4)P0=P0|0x80; delays(1); P2=_crol_(P2,1); } P2=0xef; for(n=4;n<6;n++) { P0=Ledtable[Timetable[n]]; if(n==2)P0=P0|0x80; if(n==4)P0=P0|0x80; delays(1); P2=_crol_(P2,1); } } for(i=0;i<170;i++) { show(); } }
while(k==3) { for(i=0;i<150;i++) { P2=0xfe; for(n=0;n<4;n++) { P0=Ledtable[Timetable[n]]; if(n==2)P0=P0|0x80; delays(1); P2=_crol_(P2,1); } } for(i=0;i<170;i++) { show(); } } }
modification1() interrupt 0 { TR0=0;k++; if(k==4) { k=0;TR0=1; } }
modification2() interrupt 2 { if(k==1)second++; if(second==60)second=0; if(k==2)minute++; if(minute==60)minute=0; if(k==3)hour++; if(hour==24)hour=0; }
time() interrupt 1 { TH0=0x3c; TL0=0xb0; j++; if(j==20){j=0;second++;} if(second==60){second=0;minute++;} if(minute==60){minute=0;hour++;} if(hour==24)hour=0; }
intert() { TMOD=0x01; TH0=0x3c; TL0=0xb0;
EA=1; ET0=1; TR0=1;
EX1=1; EX0=1; IT0=1; IT1=1;
PX1=1;
second=minute=hour=k=0; }
delays(uchar i) { uchar a; while(i--) for(a=0;a<85;a++); }
|