我当前的代码:
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
Stepper myStepper(stepsPerRevolution, 3, 4, 5, 6);
Stepper secondStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
secondStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
Serial.println("clockwise");
secondStepper.step(stepsPerRevolution);
delay(500);
}在上周末的一次黑客马拉松中,我正在做一个涉及上述代码的项目,但我无法让两个马达同时移动。我想知道在座的任何人是否知道如何正确地做这件事,以便我将来能更好地做好准备。
如果重要的话,我正在使用Arduino IDE。
发布于 2018-02-06 01:26:53
您需要一个非阻塞的step (或start)调用来启动运动并立即返回。在启动这两个运动之后,您将等待来自每个电动机的异步回调,表明运动已完成。每个电机一个线程将以一种简单的方式工作。主线程会等待两个电机线程完成,然后再继续。
发布于 2019-01-18 11:29:27
是的,你可以将两个马达并联,这是如何在坡道1.4板上控制z轴的!
https://stackoverflow.com/questions/48627641
复制相似问题