I have a problem with the shift register 74HC595.
The sketch I use is able to enable a specific led (8 are connected).
When I enable led 0 to 7 it behaves like normally (they switch on when I enter the numbers).
However, for the led connected to pin 15 (other side of the ic, see layout) it behaves differently. When I switch this led on, ALL leds go off. When I retry, nothing happens. When I enable another led, after a short time (but can be seconds) the led for pin 15 is emitting light together with all others which where already enabled.
This seems like a malfunction in the IC (I checked already another led, another cable, another resistor). The only think I haven't checked is moving the IC to another position of the breadboard (that would take a lot of time since I have to rewrite everything). Is it possible I missed something or is the shift register broken?
The code to switch on a led:
void updateShiftRegister()
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}
where leds are the indices of the leds (0..7).
leds
value and howleds
variable was declared (unsigned
Vs.signed
may have surprising effect on your code).