Two 74HC595 shift regesters

I am trying to build a traffic control system for my model train to have a road intersection. I am trying to use two shift registers. As I understand it, with the 74HC595's it takes serial data in one bit at a time and outputs the data in parallel. So I should be able to put in the binary pattern (LSBFIRST) and it should light up the LED's in that pattern. Now when I input my binary pattern, EX, 000001000000 it turn on pin 15 on the first register and pin 15 on the second register which means having two led's on at the same time.

Is there a trick to using these registers?

Here is the code I am using.

// Instlize the output pins on the Ardunio Mega
int latchPin = 11; // Asigns pin 12 of the IC to pin 11 on the Ardunio.
int clockPin = 9; // Asigns pin 11 of the IC the pin 9 on the Ardunio.
int dataPin = 12; // Assigns pin 14 of the IC to pin 12 on the Ardunio.

int dtrg = 500; // Set the delay timing for the Red and Green lights.

// Controls the light patterns with BINARY numbers.

int LEDs = 0b0000010000000;//Sets the red and green light cycle pattern in BINARY.

void setup() {

pinMode(latchPin, OUTPUT); // Sets pin 12 on the IC 74HC595 to pin 11 on the Ardunio.
pinMode(clockPin, OUTPUT); // Sets pin 11 on the IC 74HC595 to pin 9 on the Ardunio.
pinMode(dataPin, OUTPUT); // Sets pin 14 on the IC 74HC595 to pin 12 on the Ardunio.

// Displays the first Red and Green cycle.
void loop() {

shiftOut(dataPin, clockPin,LSBFIRST, LEDs);

Any help would be welcome.


Sounds like the registers are not in a cascade configuration - Arduino feeds 1st register, 1st register feeds 2nd register.

Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Have you googled
arduino 74hc595

Try this link they have example of two 595s.

Tom.... :slight_smile:

I only see 13 binary digits and only one (#8) set. Don't you need 16 for 2 registers?

You might do better with thinking of what you send out with "shiftout()" as "one 8 bit register at a time".

Here is why: (from the SHIFTOUT() reference documentation).

"shiftOut is currently written to output 1 byte (8 bits) so it requires a two step operation to output values larger than 255."

So, once you follow this advice, you might have better results.

That would be a good project for a stand-
alone circuit design. Why tie up a micro-
controller for a simple function like that?