Shift out more than one byte.

I'm VERY new to Arduino. I did search the forum but couldn't find an answer (at least one I could wrap my head around) so please forgive if this is elementary.

How do I send a byte "past" the first of two 74HC595 chips and through to the second? Asking about the code (not the wiring).

In simple terms, let us say I have byte A which is for the first chip and byte B which is for the second. I'd have thought that it would go something like this:

digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, LSBFIRST, B); shiftOut(dataPin, clockPin, LSBFIRST, A); digitalWrite(latchPin, HIGH);

But apparently it dont work that way....?

It does work that way.

like aarg i also do it like you describe. seems like a wiring issue?

You may have A & B swapped there, easy to tweak in the sketch tho,

I misunderstood your question. "B" should be sent first, because it must go "through" the first register. "A" follows behind, filling (1) and pushing "B" into (2).

Assuming it is wired like dataIn->1->2

Yes so its correct how he coded it. first send B then send A. the same as his example.

Thanks everyone!

Sure enough, I'm using the sim at 123dcircuits (until my starter kit arrives!)... and a whole row of parts (leds) were not connected even though they were lined up on the breadboard...but since my code confidence is so low I focused on that instead of triple checking.

Cheers.

Then it would have been helpful to explain that none of the LEDs came on. Since all you said was, "it don't work that way", we all thought you saw the bit patterns come out backwards. Just something to keep in mind if you inquire again here in future.

Thanks. I’m still learning the etiquette here for posting etc.

I was really confused because in the many many examples of code I looked at, including the tutorial here at arduino.cc, none of them used such a simple “send one, then the other” so I spent all day staring at the lesson code trying to figure out how they got it done (I still cant wrap my head around those 2-chip examples they give, but at least my few lines of code are working now :slight_smile: ).

Just think of the 2 chips as one bigger 16-bit chip.

You could write a 16 bit version of shiftOut if you wanted, its not very complicated and you have the source code with the Arduino IDE - remember this is open-source.