《基于51单片机的倒计时实现 计算机专业.docx》由会员分享,可在线阅读,更多相关《基于51单片机的倒计时实现 计算机专业.docx(4页珍藏版)》请在优知文库上搜索。
1、基于51单片机的倒计时实现U?XTAL1XTaL2P1.0PSEN.AT8Q.C61 .PO.O/ACO P0.1/AD1 PO.2/AD2 P0.3/ADG P0.4/AD4 P0.6/AC6 P0.6/AC6 PO.7/AD7P2Q P2.1/0 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2 助M4 P2.7/A16P3 0/RXD P3.1H,XD P3 2NTO P3 3NtTP3.4HD P35TT1P3BP3.7/RD啜aI-10B伯一H噎RP2RESPACKe TEXT#includedefineucharunsignedchar#defineui
2、ntunsignedintuchar11,shu,shi,ge,miao1,miao2;sbitweil=P20;sbitwei2=P2l;sbitwei3=P22;sbitwei4=P23;voiddislay(ucharshi,ucharge,ucharmiaol,ucharmiao2);ucharcodetable=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f;voiddelay(uintz)延时uintx,y;fbr(x=z;xO;x-)for(y=l10;y0;y-);)voidinit()shu=60;tl=100;TMOD=O
3、xOI;TH0=(65536-10000)/256;TL0=(65536-l0000)%256;ETO=1;/开始计时EA=I;TRO= 1;/开所有中断voidtimer()interrupt1定时器0TH0=(65536-10000)/256;TL0=(65536-l0000)%256;tl;miaol=tl10;miao2=tl%10;if(tl=0)(tl=100;shu;shi=shu10;ge=shu%10;if(shu=O)(TH0=(65536-10000)/256;TL0=(65536-10000)%256;TR0=0;voiddislay(ucharshi,ucharge,ucharmiaol,ucharmiao2)显示P2=0xfe;PO=tableshi;delay(5);P2=0xfd;PO=tablege;delay(5);P2=0xfb;PO=tablemiaol;delay(5);P2=0xf7;P0=tablemiao2;delay(5);)voidmain()init();Shi=5;ge=9;dislay(shi,ge,miaol,miao2);while(l)dislay(shi,ge,miaol,miao2);