I'm trying to control a couple of steppers via a 74HC595 shift register and a ULN2004 transistor array. I'm currently testing the setup with a single stepper but want to attach between 5 and 8, which is reason for the multiplexing.
The result I'm currently getting is as if the steppers were wired up incorrectly, i.e. they seem to take one large step CW and then three smaller steps CCW. As far as I can tell, the wiring is correct, so for now I'm inclined to think it's a code problem.
Here is what I have so far. Any suggestions are greatly appreciated.
#define latchPin 8
#define clockPin 12
#define dataPin 11
#define ledPin 13
#define numOfSteps 100
#define rate 60
#define input 0
int amp = 0;
int motorSpeed = 20;
byte dataArray[4];
byte data;
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
// step orders:
dataArray[0] = 0xAA; // 1010
dataArray[1] = 0x66; // 0110
dataArray[2] = 0x55; // 0101
dataArray[3] = 0x99; // 1001
}
void loop() {
// do numOfSteps steps and then wait for a second:
for (int i = 0; i < numOfSteps; i++) {
for (int j = 0; j < 4; j++) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, dataArray[j]);
digitalWrite(latchPin, HIGH);
delay(200);
}
}
delay(1000);
}