Hi guys
some I’m taking apart an old device, and trying to hook it up to the Particle Photon.
(thought why not hack it up to get to terms with the IOT eh).
The motor that is already in the device is a DC motor, with a Red Cable and Black Cable.
Just wondering if any tutorials out there to connect and control where its wired using just the two wires?
PS, its just a standard motor that opens and closes a flap
@dspalton, do a search for “motor control” in the Community and you’ll see lots of topics popping up! The key thing to know is that you cannot drive the motor directly from a pin on the Photon since it can’t provide enough current.
hi mate
ill have a look thank you.
got a PhoBot board here too so hoping that helps.
Got it working with a stepper motor and the tutorial, but that motor has 4 wires lol
#include "PhoBot/PhoBot.h"
PhoBot p = PhoBot(12.0, 12.0);
void setup() {
}
void loop() {
forward(500, 2);
reverse(100, 2);
}
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);
}
}
I need to hack it up to Just run off M4, not M3, and to be able to reverse as well.
Im not really good enough to be able to modify it myself.
But having seen it actually working, moving the motor, really happy
I hadnt seen that phobot board before. it uses a TB6612FNG dual H-Bridge motor controller. it will drive a single stepper or 2 DC motors. I have built some motor controllers with the same chip before, its pretty indestructible!
your best bet will be to study the schematic of the phobot and have a read of the adafruit tutorials for their boards with the same chip ( https://www.adafruit.com/products/2448 and https://www.adafruit.com/products/1438 ) Once you have an understanding of how the motors are driven you can write your own code
I just noticed in the loop section above you have 500, 2 and the code is for stepper not dc motors having said that it should still give you an output in both directions
Try changing to 5, 2000 and watch the motor should do 4sec in each direction