|
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
3.png (56.17 KB, 下載次數(shù): 17)
下載附件
2022-11-18 20:32 上傳
單片機(jī)源程序如下:- #include<reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- uint i;
- char ctime=0;
- uchar code led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- void main()
- {
- TMOD=0X01; //設(shè)定定時(shí)器為工作方式1
- TH0=(65536-45872)/256; //裝初值,11.0592 MHZ晶振定時(shí)50MS,計(jì)數(shù)值為45872
- TL0=(65536-45872)%256;
- EA=1; //打開(kāi)總中斷
- ET0=1; //打開(kāi)定時(shí)器中斷
- TR0=1; //啟動(dòng)定時(shí)器0
- while(1)
- {
- P0=led[ctime/10];
- P2=led[ctime%10];
-
- }
- }
- void time() interrupt 1 //定時(shí)器0中斷服務(wù)程序
- {
- TH0=(65536-45872)/256; //重裝初值
- TL0=(65536-45872)%256;
- i++;
- if(i==20) //如果i=20,說(shuō)明1s時(shí)間到
- {
- i=0;
-
- ctime++;
- if(ctime>99)
- {
- ctime=0;
- }
- }
- }
復(fù)制代碼
Keil代碼與Proteus仿真下載:
仿真程序.7z
(59.46 KB, 下載次數(shù): 21)
2022-11-19 23:25 上傳
點(diǎn)擊文件名下載附件
代碼何仿真圖 下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|