驱动示例如***意Stepper stepper(STEPS, 8, 9, 10, 11),改为Stepper stepper(STEPS, 8, 10, 9, 11)即可,该程序在arduino UNO板上运行后,电机正反转没有问题,但在esp8266运行时只能“单向旋转”,旋转方向或正或反。
测试后发现,将 stepper.step(2048)中的参数改为255以下,即可实现两句代码顺序执行,连续正反转。另外应用该官方Stepper容易导致esp8266 stack dumped导致重启,标志是串口出现类似如下:
esp8266驱动ULN2003带28byj四相五线步进电机时,arduino IDE中遇到的问题

/*

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it’s
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);

// the previous reading from the analog input
int previous = 0;

void setup() {
// set the speed of the motor to 30 RPMs
stepper.setSpeed(30);
}

void loop() {

stepper.step(-2048);
delay(500);
stepper.step(2048);
delay(500);
}
后确定是该库文件问题。这个库文件在当初学UNO的时候一直使用没什么问题,但是在esp8266下出现上述问题,后来在github上download了个库文件步进电机运行正常了,再也没有stack dumped,分享一下:https://download.csdn.net/download/u012893428/10686229

相关文章:

  • 2021-11-05
  • 2021-10-23
  • 2022-02-14
  • 2022-01-25
  • 2021-06-01
  • 2022-12-23
  • 2021-07-19
  • 2021-10-18
猜你喜欢
  • 2021-11-18
  • 2021-11-18
  • 2021-12-24
  • 2021-09-13
  • 2021-05-14
  • 2021-11-18
相关资源
相似解决方案