I'm not sure if I'm doing something wrong or if my IC is damaged. I'm using the code below, trying to light up an LED connected to my SN74HC595 8 bit shift register.
The correct LED lights up, but it flashes at random intervals. Pushing down on the wires makes the led solid for a moment, then it starts flashing again.
int latchPin = 5;
int clockPin = 6;
int dataPin = 4;
byte leds = 0;
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop()
{
bitWrite(leds, 0, 1); // Turn on the first LED
updateShiftRegister();
}
void updateShiftRegister()
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}
Here's a video of what the flashing looks like
Please read the forum guidelines in the sticky post to find out how to post code correctly, then edit your post above to fix it. I am quite surprised that you figured out how to post links and pictures, but somehow do not know how to post code!
Your problem: probably because you have no bypass cap on your chip. This should be 0.1uF ceramic and be placed close to the +V and ground pins of the chip.
Once you have fixed that, soon the chip or the leds will burn. You must use series resistors.
Pushing down on the wires makes the led solid for a moment, then it starts flashing again.
This is what can happen with cheap quality bread board, or even good stuff if the contacts have been stretched or the jumper leads too narrow.
Opinion is divided on the use of bread board here, some say they are good despite actually being rubbish.
Few follow up questions: Why does this work? Can I use an electrolytic capacitor? What range of values might work?
Last: when you say near +v and ground do you mean across?
Plasticity:
Last: when you say near +v and ground do you mean across?
+lead of capacitor to +V
-lead of capacitor to GND
and
as close as possible to where the +5V and GND wires from the Arduino are inserted on the breadboard.
Plasticity:
Few follow up questions: Why does this work?
See http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
Can I use an electrolytic capacitor?
Only for the bulk decoupling otherwise it has to be a ceramic one, see the link.
What range of values might work?
0.1uF ceramic AND anything from 10uF upwards depending on how much current your circuit draws.
Don't forget the resistors on the LEDs.