void motor_ffw()
{
unsigned char i;
本文引用地址:https://www.eepw.com.cn/article/201611/320045.htm for (i=0; i<8; i++) //一个周期转30度
{
P1 = FFW[i]&0x1f; //取数据
//FFW为步进码
delay(); //调节转速
}
}
void delay()
{
unsigned int k,t;
t=rate;//转速定义
while(t--)
{
for(k=0; k<150; k++)
{ }
}
}
void motor_turn()
{
unsigned char x;
rate=0x0a;
x=0x40;
do
{
mote_ffw();
rate--;//每进一步时间越来越短
}while(rate!=0x01);//处于加速过程
do
{
motor_ffw();
x--;//每减一,进一步,匀速过程
//此处同样可以设延时函数
} while(x!=0x01);
do
{
motor_ffw();
rate++; //每进一步时间越来越长
} while(rate!=0x0a);//处于减速过程
}
评论