《基于51单片机数码管100天倒计时程序(共7页).doc》由会员分享,可在线阅读,更多相关《基于51单片机数码管100天倒计时程序(共7页).doc(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上 基于51单片机数码管100天倒计时程序 (动态显示)#include Unsigned char s=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f;unsigned char e3,f3,g3,h3,count,flag0,flag2,flag3,flag4,j;void delay(unsigned char i);signed int time1=100,time0=0;void sm();void time2();void hms1 ();void timej ();void timez ();/*按键脚定
2、义*/sbit ks=P14; sbit hms=P15; sbit add=P16;sbit bat=P17;void sm()/*数码管显示位*/e3=time1/100;f3=time1%100/10;g3=time1%100%10;P2=0x01; P0=sf3;delay(2);P0=0;P2=0x02;P0=sg3;delay(2);P0=0;P2=0x04;P0=se3;delay(2); P0=0;void main()TMOD=0x01;TH0=0x3c;TL0=0xb0;EA=1;ET0=1; while(1)sm();time2();hms1();timej();time
3、z();void time2() /计时开始if(ks=0)delay(10);if(ks=0)flag0=1;if(flag0=1&ks=1)flag0=0;TR0=1; void hms1 () /按键变量jif (hms=0)delay (10);if(hms=0) flag2=1; if(flag2=1&hms=1) flag2=0; j+;TR0=0; if (j=3) j=0; void timez () /按键加if (add=0)delay (10);if(add=0) flag4=1; if(flag4=1&add=1) flag4=0; switch(j) case 0x0
4、0:break; case 0x01:time1+; break; case 0x02:time1=time1+10;break; default:break;void timej ()/按键减if (bat=0)delay (10);if(bat=0) flag3=1; if(flag3=1&bat=1) flag3=0; switch(j) case 0x00:break; case 0x01:time1-;break; case 0x02:time1=time1-10;break; default:break;void int1()interrupt 1 count+; if(count=12) count=0; time0+; if(time0=8640) time1-; time0=0; if(time1=-1) time1=100; void delay(unsigned char i )unsigned char j,k;for (k=0;ki;k+)for (j=0;j10;j+);专心-专注-专业