#include <reg52.h>
//unsigned char code F_Rotation[4]={0x12,0x06,0x0c,0x18};
//unsigned char code F_Rotation[8]={0x12,0x02,0x06,0x04,0x0c,0x08,0x18,0x10};//一二相激励
unsigned char code F_Rotation[4]={0x02,0x04,0x08,0x10};//正转表格
unsigned char code B_Rotation[4]={0x10,0x08,0x04,0x02};//反转表格
void Delay(unsigned int i)//延时
{
while(--i);
}
main()
{
unsigned char i;
while(1)
{
for(i=0;i<4;i++) //4相
{
P1=F_Rotation[i]; //输出对应的相 可以自行换成反转表格
Delay(280); //改变这个参数可以调整电机转速
}
}
}
温馨提示:内容为网友见解,仅供参考