60倒計(jì)時(shí)數(shù)碼管的源文件
單片機(jī)源程序如下:
- #include<reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar code table[]={
- 0x3f,0x06,0x5b,0x4f,
- 0x66,0x6d,0x7d,0x07,
- 0x7f,0x6f};
- void delay(uint xms);
- void display(uchar shi,uchar ge);
- uchar num1,num2,shi,ge;
- void main()
- {
- num1=60;
- TMOD=0x11;
- EA=1;
- ET0=1;
- TR0=1;
- while(1)
- { display(shi,ge);
- if(num2==20)
- {
- num2=0;
- num1--;
- if(num1==00)
- num1=60;
- shi=num1/10;
- ge=num1%10;
- }
- }
- }
- void display(uchar shi,uchar ge)
- {
- P1=table[shi];
- P2=0xfb;
- delay(5);
- P1=table[ge];
- P2=0xf7;
- delay(5);
- P2=0xfc;
- P1=0x3f;
- delay(5);
- }
- void delay(uint xms)
- {
- uint y,z;
- for(y=xms;y>0;y--)
- for(z=110;z>0;z--);
- }
- void time1() interrupt 1
- {
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- num2++;
- }
復(fù)制代碼
所有資料51hei提供下載:
60秒倒計(jì)時(shí)!.rar
(24.95 KB, 下載次數(shù): 13)
2018-7-15 18:18 上傳
點(diǎn)擊文件名下載附件
|