Help needed with shift registers

Yes I agree with you, failures are there to learn from as we say in Holland :).

Luckily the chip still works fine, I just keep it for experimenting and use new shift registers for my cube;).

I still have a small 'problem'. The shift registers are hooked up to the arduino (3 digital pins, GND and 5V), when I put my USB cable in my laptop all the LEDS light up for a second and then just run the code I what was uploaded to the arduino. Is there any way to let the LEDs not light up whenever I connect my arduino to my laptop?
Vid:

Try a 10k resistor between latch and ground.

Thanks for the tip! Now the LEDs won't light up when i connect the USB to my laptop!

Btw: Does every latch pin from each shift register need a resistor to ground? I tie all the latches from each shift register (6 in total) together

I don't think every latch need a resistor though

Sorry, I think I got that the wrong way round - try to +5v! It won't have done any harm.

It holds the line high while the processor is sorting itself out. However if the processor drags it low then it could shift out data to the registers.

It's a suggestion from Nick Gammon: http://gammon.com.au/forum/?id=11518

No you was right! The latch pin should be low so no data will be send to the outputs. If i put the resistor on 5v and the latch then the latch will be high, if i tie it to GND then it is low(atleast it's working if i put the resistor between latch and ground). However i'm not sure if I need to place a resistor on every latch pin or only 1 resistor from latch to ground will be good enough (notice that all the latches from the 6 registers are tied together).

One resistor should suffice for all the registers.

Ok thank you very much :)! Then i put around a 10k resistor between the latch and gnd on my 5x5x5 cube.

Did some testing with 2 different codes today(changed the code in something easier for the forum):

1:

void loop(){
shiftOut(dataPin, clockPin, MSBFIRST, B00001);
digitalWrite(latchPin, HIGH);
delay(500);
digitalWrite(latchPin, LOW); 
}

2:

void loop(){
shiftOut(dataPin, clockPin, MSBFIRST, B00001);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
delay(500);
}

As you can see the difference is the place of the delay(). I uploaded both codes, and both looks exactly the same, so i can assume it does not care where i place the delay?

]

That's a rather strange way of ordering the events!

The sequence is:

Latch low
Data out
Latch high.

If you want to add a delay it should ideally be outside this sequence.

Then I will use your sequence, after all it looks like the best sequence out of the three i can choose. Thanks again!

So i got my cube working and all :). Only thing is that i still get a really faint flash on all leds (pretty hard to see because its maybe on for a millisecond or so). I tried lowering my pull down resistor to 3k but i still see the flashes. Maybe someone know why I still get flashes??

WonderTiger:
So i got my cube working and all :). Only thing is that i still get a really faint flash on all leds (pretty hard to see because its maybe on for a millisecond or so). I tried lowering my pull down resistor to 3k but i still see the flashes. Maybe someone know why I still get flashes??

I suspect it's the way you are managing the latching sequence Vs level enabling, but just a guess. You should enable a level only after all the shifting of data for that level is done and the latch set to output the value, only then should you enable that level for the time duration you have set for your scan timing, then disable that level, do the shifting/latching for the next level and then enable that next level. Lather, rinse, repeat.

Lefty

The problem is not with latching data out, but the leds are flashing when i connect my arduino to my laptop via usb (so when the arduino gets powered up). So im already using a pull down resistor on the latch I get significant less flashing on powering up. However its not completely gone(like 1ms flash or so).

Have you considered a pullup on the shift register's OE pin, and have your sketch pull it low when you're ready for output to begin showing up?

Im going to try a 10k from OE to 5V and see if that works, ill report back!

Btw, i wrote a piece of code in the void setup to put all latches to low and shift out B00000 (each zero is a LED in off state) to all shift registers

So I tryed it on a single shift register but no luck, its still flashing when getting powered up. However when I put a 10k resistor on the latch to ground on a single shift register on my breadboard it won't flash at all, but on my cube with 6 registers it will flash when using a 10k pull down resistor.

Well, 10K is only 0.5mA of pulldown - you could go stronger, like 1K for 5mA of pulldown. Arduino will drive it high okay.

So I tried 1k, still some very faint flashes on powering up :frowning:

Got it fixed, I was so stupid to shift out B00001 instead of B00000 at the void setup(I shift out B00000 to clear out all the shift registers). So I got it fixed :)!