|
所有管腳的連接均在config.h文件夾下,用的單片機是STC15W408AS,實現(xiàn)功能數(shù)碼管計時清零,按鍵調(diào)節(jié)加減速(同時燈對應(yīng)亮起)
另附定時器中斷測試程序(希望對定時器中斷的理解有幫助)
各引腳有效位
位選 0 十位P35 個位P27
P24=1 段選 1 P1
P25=1 燈 1 P1
P33=0 蜂鳴器
P26 電機 (直接連接)
P21 按鍵 K1
P20 K2
P36 K3
P37 K4
P34 J5
單片機源程序如下:
- #include "config.h"
- #include "init.h"
- #include "led.h"
- #include "lcd.h"
- #include "dj.h"
- extern unsigned int j;
- extern unsigned int i;
- void main()
- {
-
- TMOD=0X01; /*中斷初始化*/
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- EA=1; //中斷總開關(guān)
- ET0=1; //請求中斷
- TR0=1; //允許中斷
-
- //init();
- pwm();
- while(1)
- {
- //
- // cpwm();
- // j=1;
- // display(num);
-
- if(k1 == 1)
- {
-
- display();
- k1=0;
- display();
- cpwm();
- led1=1;
- di();
- if(k2 == 1)
- {
-
- k2=0;
- j++;
- i++;
- di();
-
- }
- if(k3 == 1)
- {
-
- k3=0;
- j--;
- i--;
- di();
-
- }
- if(k4 == 1)
- {
- P0=0x3f;//為0
- k4=0;
-
- }
-
- }
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
massage.zip
(37.5 KB, 下載次數(shù): 43)
2020-10-21 14:39 上傳
點擊文件名下載附件
STC15W408AS 28引腳驅(qū)動電機 數(shù)碼管 燈
|
|