网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
06月30日漏签0天
arduino吧 关注:75,332贴子:230,136
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 1回复贴,共1页
<<返回arduino吧
>0< 加载中...

【求教】关于电位器控制步进电机

  • 只看楼主
  • 收藏

  • 回复
  • 6699cn
  • 崭露头角
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
比如用手拧电位器转一圈,电机也跟着转一圈。


  • 6699cn
  • 崭露头角
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
求大神看看代码出什么问题了?
#include <AccelStepper.h>
#include <AFMotor.h>
#define encoderpinA 53
#define encoderpinB 51
int encoderpos = 0;
int encoderpinAlast = LOW;
int encoderpinBlast = LOW;
int n = LOW;
AF_Stepper motor2(48, 2);
void forwardstep2() {
motor2.onestep(FORWARD,SINGLE);
}
void backwardstep2() {
motor2.onestep(BACKWARD,SINGLE);
}
AccelStepper stepper2(forwardstep2, backwardstep2);
void setup()
{
pinMode(encoderpinA,INPUT_PULLUP);
pinMode(encoderpinB,INPUT_PULLUP);
}
void loop()
{
n = digitalRead(encoderPinA);
if((encoderPinAlast !=n)){
if(((n == HIGH) && (digitalRead(encoderPinB == LOW)) ||
((n == LOW) && (digitalRead(encoderPinB == HIGH))) {
motor.step(100,FORWARD,MICROSTEP);
} else {
motor.step(100,FORWARD,MICROSTEP);
}
} else {
n = digitalRead(encoderPinB);
if((encoderPinBlast !=n)){
if(((n == HIGH) && (digitalRead(encoderPinA == LOW)) ||
((n == LOW) && (digitalRead(encoderPinA == HIGH))) {
motor.step(100,FORWARD,MICROSTEP);
} else {
motor.step(100,FORWARD,MICROSTEP);
}
}
}
encoderPinAlast = digitalRead(endcoderPinA)
encoderPinBlast = digitalRead(endcoderPinB)
}
自己修改了些.....但还是有很多错误提示:
__.ino: In function *void loop()*:
__.ino:31:19: error: *encoderPinA* was not declared in this scope
__.ino:32:6: error: *encoderPinAlast* was not declared in this scope
__.ino:33:37: error: *encoderPinB* was not declared in this scope
__.ino:34:59: error: expected *)* before *{* token
__.ino:36:10: error: expected *)* before *else*
__.ino:39:3: error: expected primary-expression before *}* token
__.ino:39:3: error: expected *;* before *}* token
__.ino:40:21: error: *encoderPinB* was not declared in this scope
__.ino:41:10: error: *encoderPinBlast* was not declared in this scope
__.ino:43:59: error: expected *)* before *{* token
__.ino:45:10: error: expected *)* before *else*
__.ino:48:6: error: expected primary-expression before *}* token
__.ino:48:6: error: expected *;* before *}* token
__.ino:50:3: error: *encoderPinAlast* was not declared in this scope
__.ino:50:33: error: *endcoderPinA* was not declared in this scope
__.ino:51:3: error: expected *;* before *encoderPinBlast*


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 1回复贴,共1页
<<返回arduino吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示