Hey all,
I’ve recently installed an awesome Automated Blinds for my office window using a Photon and a stepper motor (see code below). However, I’ve noticed that after I trigger the “Open” or “Close” buttons from my webpage, the motor continues a loud annoying buzz even after the motor stops moving. Before clicking either button, the motor is nice and quiet. And when I re-flash the Photon and it’s sitting waiting to be used, the motor is also quiet. The buzz just kicks in after I’ve used the motor.
Does anyone have an idea for how to reset the motor to that initial “sleeping” mode after use so I don’t have this loud buzz all day??
#include "PhoBot/PhoBot.h"
PhoBot p = PhoBot(12.0, 12.0);
int numSteps = 2080; // figure out how many steps you need to open the curtains, and change this number to that
int period = 3;
bool curtainsAreOpen;
void setup() {
Particle.function("motor", motorSwitcher);
curtainsAreOpen = true;
}
void loop() {
}
int motorSwitcher(String command) {
if(command.equalsIgnoreCase("on") && curtainsAreOpen){ // I'm assuming that the "on" direction closes the curtains.
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);
}
curtainsAreOpen = false;
}else if (!curtainsAreOpen){
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);
}
curtainsAreOpen = true;
}
}