Hey everyone,
I recently bought a Photon, Stepper Motor, and Phobot Board to control a motor remotely. Since this is my first project with C, I just followed Simon Monk’s tutorial (link here and code copied below). After flashing the software, the motor started spinning successfully in one direction.
However, it’s supposed to then reverse direction and spin the other way… but it just freezes momentarily and makes a buzzing noise. So it’s only spinning successfully in one direction right now. Any ideas?
#include "PhoBot/PhoBot.h"
PhoBot p = PhoBot(12.0, 12.0);
void setup() {
}
void loop() {
forward(100, 5);
reverse(100, 5);
}
void forward(int numSteps, int period) {
for (int i = 0; i < numSteps; i++) {
p.setMotors("M3-F-100");
p.setMotors("M4-B-100");
delay(period);
p.setMotors("M3-F-100");
p.setMotors("M4-F-100");
delay(period);
p.setMotors("M3-B-50");
p.setMotors("M4-F-50");
delay(period);
p.setMotors("M3-B-50");
p.setMotors("M4-B-50");
delay(period);
}
}
void reverse(int numSteps, int period) {
for (int i = 0; i < numSteps; i++) {
p.setMotors("M3-B-100");
p.setMotors("M4-B-100");
delay(period);
p.setMotors("M3-B-100");
p.setMotors("M4-F-100");
delay(period);
p.setMotors("M3-F-50");
p.setMotors("M4-F-50");
delay(period);
p.setMotors("M3-F-50");
p.setMotors("M4-B-50");
delay(period);
}
}