|
- #include <reg52.h>
- unsigned char code F_Rotation[4]={0x02,0x04,0x08,0x10};//正轉(zhuǎn)表格
- unsigned char code B_Rotation[4]={0x10,0x08,0x040,0x02};//反轉(zhuǎn)表格
- void Delay(unsigned int i)//延時
- {
- while(--i);
- }
- main()
- {
- unsigned char i;
- while(1)
- {
- for(i=0;i<4;i++) //4相
- {
- P1=F_Rotation[i]; //輸出對應(yīng)的相 可以自行換成反轉(zhuǎn)表格
- Delay(500); //改變這個參數(shù)可以調(diào)整電機(jī)轉(zhuǎn)速
- }
- }
- }
復(fù)制代碼 |
|