I’m very new at all this and I’m trying to get one of my motors (12v) to spin continuously and the other one move half way back and forth
I’m using a UNO R3, have 2 A4988 drivers, and the 2 12v motors.
I also want to make it so I only have 1 power input rather than powering the Arduino with a usb AND the motors with a separate 12v power supply
My current setup is (as best as possible)
Motor 1:
Step/Dir in port 2/3 of the arduino
Motor 2:
Step/Dir in port 4/5
The VIN & GND of the arduino are wired to the first slot of the top rail of my breadboard.
Next to that is a 100uF capacitor
Then I have 2 pairs of positives and negatives going to each VMOT and GND of the drivers.
The 5v & GRN of the Arduino are wired to the bottom rail of the bread board and then I have a pair of POS and NEG going to VDD & GND of the driver
My motors seem to be stuttering with the code I have BUT I also don’t know if I did my code correctly.
What is the best way to wire up TWO 12V motors to come from a SINGLE power source (arduino port or external power supply) AND what is the best code for it??
I’m a very visual learner and don’t know a lot of technical terms, I know the stuff I can see on my drivers and arduino lol
CODE:
#include <AccelStepper.h>
#include <MultiStepper.h>
// Define some steppers and the pins the will use
AccelStepper stepper1(2, 3); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper2(4, 5);
MultiStepper steppersControl;
long gotoposition[3];
void setup()
{
stepper1.setMaxSpeed(1000);
stepper2.setMaxSpeed(1000);
steppersControl.addStepper(stepper1);
steppersControl.addStepper(stepper2);
}
void loop() {
gotoposition[0] = 1000;
gotoposition[1] = 1000;
steppersControl.moveTo(gotoposition);
steppersControl.runSpeedToPosition();
delay(1000);
gotoposition[0] = 0;
gotoposition[1] = 0;
steppersControl.moveTo(gotoposition);
steppersControl.runSpeedToPosition();
delay(1000);
