资源描述:
《单片机数码管动态显示实例.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#defineuintunsignedintsbitp12=P1^2;sbitp21=P2^1;sbitp22=P2^2;sbitp23=P2^3;sbitp24=P2^4;sbitp10=P1^0;chartab1[]={0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xa4,0xf9,0xc0};chartab2[]={0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xa4,0xf9,0xc0};chartab3[]={0x90,0x80,0xf8,0x82,
2、0x92,0x99,0xb0,0xa4,0xf9,0xc0};chartab4[]={0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xa4,0xf9,0xc0};uinta=0;uintb=0;uintc=0;uintd=0;voidDelay(uinti);voidmain(){TMOD=0x01;TH0=0xff;TL0=0x00;EA=1;ET0=1;TR0=1;p10=0;while(p10==0){p24=0;P0=tab1[a];Delay(200);p24=1;p23=0;P0=tab2[b];Delay
3、(200);p23=1;p22=0;P0=tab3[c];Delay(200);p22=1;p21=0;P0=tab4[d];Delay(200);p21=1;}while(1){p24=0;P0=0x88;Delay(200);p24=1;p23=0;P0=0x23;Delay(200);p23=1;p22=0;P0=0xa3;Delay(200);p22=1;p21=0;P0=0x83;Delay(200);p21=1;}}voidTimer0()interrupt1{TH0=0xff;TL0=0x00;if(p24==0&&P0==0xc
4、0){if(p23==0&&P0==0xc0){if(p22==0&&P0==0xc0){if(p21==0&&P0==0xc0){p10=1;}else{d++;c=0;b=0;a=0;}}else{c++;b=0;a=0;}}else{b++;a=0;}}else{a++;}}voidDelay(uinti){for(;i>0;i--){;}}