这个实现比较容易,难点是确定这个10-15秒的延时是否准确,这个自己可以调
#include <reg52.h>
unsigned char code F_Rotation[4]={0x040x080x100x20};//正转表格
unsigned char code B_Rotation[4]={0x200x100x080x04};//反转表格
void Delay(unsigned int i)//延时
{
while(--i);
}
main()
{
unsigned char i;
while(1)
{
for(i=0;i<4;i++) //4相
{
P3=F_Rotation[ i]; //输出对应的相 可以自行换成反转表格
Delay(750*10); //改变这个参数可以调整电机转速
}
Delay(1000*10); //这个参数自己调,调为10-15秒
for(i=0;i<4;i++) //4相
{
P3=B_Rotation[ i]; //输出对应的相 可以自行换成反转表格
Delay(750*10); //改变这个参数可以调整电机转速
}
Delay(1000*10); //这个参数自己调,调为10-15秒
}
}