c语⾔错误stray,【求教】error:strayinprogram这个错误是什
么意思
该楼层疑似违规已被系统折叠隐藏此楼查看此楼
intLeftI1=9;//连接电机驱动板的CP+接⼝
intLeftI2=5;//连接电机驱动板的CW+接⼝
intRightI1=10;//连接电机驱动板的CP-接⼝
intRightI2=6;//连接电机驱动板的CW-接⼝
intStepCount=0;//定义初始步数为0
intStepDelayTime=200;//定义单个脉冲时间为200(us)
intval;
intState;//定义状态变量
intStartDelay=1000;//定义启动速度
intDelaytime=100;//定义加速度,减速度10
voidtup()//接⼝定义
{
pinMode(LeftI1,OUTPUT);//I1和I2都是数字信号
pinMode(LeftI2,OUTPUT);//通过设置I1和I2来控制电机旋转⽅向
pinMode(RightI1,OUTPUT);//I1和I2都是数字信号
pinMode(RightI2,OUTPUT);//通过设置I1和I2来控制电机旋转⽅向
(9600);//设置波特率
}
voidForwardInit()//接⼝初始化定义,正转
{//20
digitalWrite(LeftI1,LOW);//CP+=0
digitalWrite(LeftI2,LOW);//CW+=0
digitalWrite(RightI1,LOW);//CP-=0
digitalWrite(RightI2,HIGH);//CW-=1
StepCount=0;//步数初始化
}
voidBackwardInit()//接⼝初始化定义。反转
{
digitalWrite(LeftI1,LOW);//CP+=0
digitalWrite(LeftI2,LOW);//CW+=030
digitalWrite(RightI1,LOW);//CP-=0
digitalWrite(RightI2,HIGH);//CW-=1
StepCount=0;
}
voidStopwardInit()//停⽌时接⼝定义
{
digitalWrite(LeftI1,LOW);//CP+=0
digitalWrite(LeftI2,LOW);//CW+=0
digitalWrite(RightI1,LOW);//CP-=0
digitalWrite(RightI2,LOW);//CW-=040
}
voidForwardOneStep()//定义正向启动语句
{
delayMicroconds(StepDelayTime);//延迟函数
switch(StepCount)//switch语句,选择步数
{
ca0://步数为0
digitalWrite(LeftI2,HIGH);
digitalWrite(LeftI1,HIGH);
break;//跳出50
ca1://步数为1
digitalWrite(LeftI1,LOW);
digitalWrite(RightI2,HIGH);
break;//跳出
ca2://步数为2
digitalWrite(RightI2,LOW);
digitalWrite(RightI1,HIGH);
break;//跳出
ca3://步数为3
digitalWrite(RightI1,LOW);//60
digitalWrite(LeftI2,LOW);
break;//跳出
}
StepCount=(StepCount+1)%4;//取余函数,每次步数增加1,完成步进功能
}
voidBackwardOneStep()//定义反向步进启动句
{
delayMicroconds(StepDelayTime);//根据步进电机转动时序图编写各段步数
switch(StepCount)
{//70
ca0:
digitalWrite(LeftI2,HIGH);
digitalWrite(LeftI1,HIGH);
break;
ca1:
digitalWrite(LeftI1,LOW);
digitalWrite(RightI2,HIGH);
break;
ca2:
digitalWrite(RightI2,LOW);//80
digitalWrite(RightI1,HIGH);
break;
ca3:
digitalWrite(RightI1,LOW);
digitalWrite(LeftI2,LOW);
break;
}
本文发布于:2023-01-04 16:21:04,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/90/91628.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |