I just started messing with shift registers and started off with shiftOut() - Arduino Reference http://arduino.cc/en/Tutorial/ShiftOut and few other web pages google came up with.
Currently I have single 74HC595 hooked up to an Uno, just the way it is connected here, with one difference. I don't have a 0.1"f capacitor (I suppose that is 0.1?F?) at hand so I tried without it.
The problem manifests in the way that although all the LEDs function at some time, they don't always light up. For example, in my attempt to pinpoint the problem I dumbed down the code to count to 9, took out all the ifs and loops and fancy variables. It now looks like this:
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
delay(1);
digitalWrite(latchPin, HIGH);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 1);
delay(1);
digitalWrite(latchPin, HIGH);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 2);
digitalWrite(latchPin, HIGH);
delay(1);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 3);
digitalWrite(latchPin, HIGH);
delay(1);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 4);
digitalWrite(latchPin, HIGH);
delay(1);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 5);
delay(1);
digitalWrite(latchPin, HIGH);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 6);
delay(1);
digitalWrite(latchPin, HIGH);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 7);
delay(1);
digitalWrite(latchPin, HIGH);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 8);
delay(1);
digitalWrite(latchPin, HIGH);
delay(1000);
digitalWrite(latchPin, LOW);
delay(1);
shiftOut(dataPin, clockPin, MSBFIRST, 9);
delay(1);
digitalWrite(latchPin, HIGH);
delay(1000);
}
See? Can't be much dumber than this.
The code is supposed to light up the LEDs and represent the numbers in binary. However, it skips some numbers entirely. For example, after the number three which is represented with LEDs one and two, all LEDs turn off until it is time for number five (LEDs three and one). Six also doesn't work at all, but seven (first three diodes) happily glows correctly like nothing happened.
Working and non working numbers are randomly interchanging so every number eventually lights up at exactly the right time, showing that everything is hooked up correctly, that arduino is sending the numbers at the right time.
Could all this come from the lacking cap? I tried 10?F (the only one I had around) but the problem just changes slightly (half works for a bit just like before, then completely freezes until the cap is removed).