Hello community
I wish to control 6 mini stepper motors (12V 28BYJ-48) independently with the Arduino uno over motor driver breakouts (ULN2003A). Already, I wired one breakout and stepper motor and it worked really well for my purpose. For the controls I used the AccelStepper library because I need acceleration.
Because there are at least 4 digital pins per motor drivers needed on the Arduino, I researched for a solution but couldn't get any - at least for my specific setup.
Now I thought of controlling the motor drivers via a shift register (sn74hc595). That way it should be possible to control 6 motor drivers over only 3 digital pins. But for now, I just want to control 1 motor drivers as a first test.
The problem is that the AccelStepper library just sends data to the pins directly when stepper.runSpeed() is executed. This data should now go to the shift register instead to the pins. But I couldn't find out how to intercept the data that is sent from the AccelLibrary. Is there a way?
I haven't much useful code for now because I'm really stuck at getting the informations I need from the AccelLibrary.
#include <AccelStepper.h>
#include <ShiftRegister74HC595.h> // Maybe it's not a good idea to use this library?
// Motor pin definitions:
#define motorPin1 2
#define motorPin2 2
#define motorPin3 2
#define motorPin4 2 // I set this all to 2 because it's the data channel of the shift register. Maybe it's possible to set variables here instead of pins?
// 4 wire motor
#define MotorInterfaceType 8
// 2 is the data channel
ShiftRegister74HC595<1> sr(2, 3, 4);
AccelStepper stepper = AccelStepper(MotorInterfaceType, motorPin1, motorPin3, motorPin2, motorPin4);
void setup() {
Serial.begin(9600);
stepper.setMaxSpeed(1000);
}
void loop() {
stepper.setSpeed(500);
sr.setAllHigh(); // Maybe it's possible to set all pins high and then send rundSpeed()?
stepper.runSpeed(); // Or get the data of the single (4) pins and run it through the shift register afterwards?
}
(motor is connected of 5V of Arduino for testing purpose) Wiring on the picture should fit my idea but maybe you even have any better idea to control 6 motors via 1 or 6 motor drivers?
Cheers and best regards, Tesla4