分享一個51單片機控制的計時秒表程序和仿真,帶有開始/停止按鈕和 清0按鈕.
單片機源程序如下:
- #include<reg51.h>
- #include"fun.h"
- void INT0_interrupt() interrupt 0
- {
- running=~running;
- if(running)
- {
- TR0=1;
- }
- else
- {
- TR0=0;
- }
- }
- void Timer0_interrupt() interrupt 1
- {
- TH0=T0_50ms>>8;
- TL0=T0_50ms;
- if((++count_in_T0)==20)
- {
- count_in_T0=0;
- if((++display_num)==60)
- {
- display_num=0;
- }
- }
- }
- main()
- {
- unsigned char shi,ge;
- init_port();
- init_int();
- init_timer();
- display_num=0;
- count_in_T0=0;
- running=0;
- en2=1;
- en1=1;
- EA=1;
- while(1)
- {
- shi=display_num/10;
- ge=display_num%10;
- display(shi,ge);
- if(clear==0)
- {
- ms_delay(10);
- if(clear==0)
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
計時秒表.zip
(53.79 KB, 下載次數: 156)
2017-5-30 20:23 上傳
點擊文件名下載附件
|