《51单片机定时器数码管30秒倒计时(三个按键控制开始暂停复位)》由会员分享,可在线阅读,更多相关《51单片机定时器数码管30秒倒计时(三个按键控制开始暂停复位)(3页珍藏版)》请在金锄头文库上搜索。
1、精选优质文档-倾情为你奉上51单片机定时器数码管30秒倒计时(带三个按键控制开始,暂停,复位)程序:#include at89x51.hunsigned char code led10=0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F;unsigned char code addr2=0xef,0xdf;unsigned char xx2;unsigned char time=30;unsigned char flag=0;void delay(void);void sys(void)TMOD=0x01;TH0=(65536 - 50000)
2、/ 256; TL0=(65536 - 50000) % 256;ET0=1;TR0=1;EA=1;EX0=1;IT0=1;void ftimer0(void) interrupt 1static unsigned char cnt;TH0=(65536-50000)/256; TL0=(65536-50000)%256;cnt+;if(cnt20)if(flag=1)time-;cnt=0;if(time=0)ET0=0;TR0=0; void int0(void) interrupt 0 if(P2_0=0) flag=1;ET0=1;else if(P2_1=0)ET0=0;else if(P2_2=0) time=30;ET0=0;TR0=1;void main()unsigned char a;sys();for(;)for(a=0;a2;a+)xx0=time/10;xx1=time%10;P0=ledxxa;P1=addra;delay();P1=0xff;void delay(void) long t=100; while (t-);电路图及结果:专心-专注-专业