74HC595N problem, 8 LED one-by-one

I am new to the forums and almost as new to electronics and arduino.

I am trying to controll 8 LED with 74HC595N. Using a Arduino Uno(sunfounder)

I have followed this guide:
LINK TO TUTORIAL

and also added a 0.1µF capacitor to pin12 on 595(latch) -> GRN

When I boot up the arduino the loop runs good for maybe 3-8 cycles (varies)
Then the LEDs go out for about 3-10sek (varies)
Then the LEDs start the loop again from where they stoped but this time less loops and so on..

After a couple of loops-stop-loops-stop the led stop lighting up at all

If I dissconnect the power to the arduino for a couple of sek and plug it in again the same happens again.

What can be the problem here? Seems to work for other ppl..
Is the 595chip broken?
May it be the arduino?(havent hade any problems with it so far)

excuse any typos, enligsh is my 2nd language :slight_smile:

EDIT: well I managed to find another 74HC595N chip and it does the exact same thing so I am guessing its not the 595 chop

The Arduino is connected to laptop via USB if that helps. Tried all 5 USB ports with same result.
Laptop is connected to wall

Hi, welcome to the forum.

It seems to be the same as this tutorial : http://arduino.cc/en/tutorial/ShiftOut. I never used a capacitor at the latch pin and I think it is wrong. I'm pretty sure it is wrong.

This is a tutorial by Adafruit, and they don't use that capacitor : Overview | Arduino Lesson 4. Eight LEDs and a Shift Register | Adafruit Learning System

This is the most simple example I could find : ExempleDémultiplexeurNumérique74HC595 @ Arduino @ t-o-f

Remove that capacitor from the latch. You could try the code from those examples for Adafruit or wiki.t-o-f.info (change the pin numbers in the sketch according to your wiring).

A common problem is no decoupling and bad breadboard contacts. Could you add a capacitor at the 5V and GND on the breadboard. That is to decouple the power for the 74HC595.

Thx, Peter

The wireing looks exactly the same on all the examples as far as I can see, right?
Apart from the capacitor that is...

I did try without a capacitor at firts, added it when having problems.
But I will try moving it to go from + to - on the breadboard and see what happends.

I will also try the codes from the examples you linked and see if it works better.

I did move the 595 chip on the breadboard when trying a diffrent 595 chip.
Doing so all the connecting wires to the 595 also change.

But I guess I need to move everything to find out if the breadboard is bad at some contact.

Thx for the reply. Lets hope I find the here solution

apmuskel:
Thx for the reply. Lets hope I find the here solution

Sometimes it helps to rip everything apart, toss code in the bin an start fresh from the start.
At some point you do not see the mistakes you make.

No Caps On Control Signals!
I can’t believe that is still shown there. We have been complaining about that since At Least Aug 2010 when I joined the forum.

Here’s a simple sketch to test your hardware.
Make sure you have MasterClear connected to +5, OE/ connected to GND.
SRCLK connected to SCK (D13),
Serial In to MOSI (D11),
RCLK to SS (D10).
0.1uF cap from Vcc to GND

#include <SPI.h>
byte ssPin = 10;
// array: assumes HC595 High output connects to anode, cathode to resistor to Gnd.
byte array[] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x80, 0x40, 0x2, 0x10, 0x08, 0x04, 0x02, 0x01,};
byte x;
void setup(){
pinMode (ssPin, OUTPUT);
digitalWrite (ssPin, HIGH);
SPI.begin();
}
void loop(){
for (x = 0; x<16; x=x+1){
digitalWrite (ssPin, LOW);
SPI.transfer (array[x]); // send data from array to shift register
digitalWrite (ssPin, HIGH); // shift register outputs updated on this rising edge
delay(200);
}
}

Then if you want 2-3 light on at a time, just adjust the array, for example:
x0000000
xx000000
xxx00000
0xxx0000
00xxx000
000xxx00
0000xxx0
00000xxx
000000xx
0000000x
0000000x
000000xx
00000xxx
0000xxx0
000xxx00
00xxx000
0xxx0000
xxx00000
xx000000
x0000000

and loop from 0 to 19 vs 0 to 15

well I do feel a bit stupid now for taking up all of your time.
MasterClear was not connected to my breadboard + line..had missed by one hole.

I was so sure I had made all the connections right and even tripple checked them

All works fine now

Thx thou for all your help!

CrossRoad,
Thats a nice simple code. Good for a beginner like me.
Is there a way to implement similar code if i hook up 2 74hc595 in parallel?

Very nice that you have it working, and don't worry, such things happen to all of us.

Parallel ? wouldn't your rather cascade them ?
For parallel, you could use two seperate ssPin and in the code make the one you want to use LOW and HIGH.