上面我們雖然完成了用中斷控制電機(jī)轉(zhuǎn)動(dòng)的程序,但實(shí)際上這個(gè)程序還是沒(méi)多少實(shí)用價(jià)值的,我們不能每次想讓它轉(zhuǎn)動(dòng)的時(shí)候都上下電啊,是吧。還有就是它不但能正轉(zhuǎn)還得能反轉(zhuǎn)啊,也就是說(shuō)不但能轉(zhuǎn)過(guò)去,還得能轉(zhuǎn)回來(lái)呀。
#include<reg51.h>#define uint unsigned int #define uchar unsigned char #define ms *77 // f = 12 M #define LEDLen 4 #define Dj_star() {IE=0x81; pri_dj=0; } #define Dj_stop() {IE=0x00; pri_dj=1;
#include<reg51.h>#define uint unsigned int #define uchar unsigned char #define ms *77 // f = 12 M #define LEDLen 4 #define Dj_star() {IE=0x81; pri_dj=0; } #define Dj_stop() {IE=0x00; pri_dj=1;