[SOLVED] Two Or More 74HC595 SR's On Uno

Hi everyone :slight_smile:

Firstly I would just like to say hello. My name is James and I'm from S.E London in the U.K.

I'm currently having a problem getting two or more shift registers to work on the Arduino Uno. I've learnt alot over the last few months, and any problems I've encountered I've muddled through and solved either by myself, or by reading this brilliant forum.

However, I'm totally stuck trying to figure out how to operate all or each output on two or more shift registers individually. I've read the 'shiftOut' tutorial, and I've also looked at some other peoples shift register projects on the internet, but I can't get them to do what I want them to.

Basically I want to create a bargraph display using LEDs, and I can achive this by using one shift register, but when I use two or more, they are copying what the first one does. I can understand that you are outputting 8 bits per SR which makes a byte. What I can't work out is how to operate the shift registers or bytes individually by turning on specific outputs or bits.

I think I must have the electronics engineers version of 'writers block' because it's just not sinking in. I'm blaming that on the long hours I've been working over the last couple of weeks lol.

I would genuinely appreciate any help or advice you guys have to offer.
Many thanks
James

Hi James, have you got the serial out from the first 595 going to the serial in of the second? (the clock and latch lines are paralleled to all the chips.)

And after you take the latch low you must send enought data - 2 bytes, to fill both shift registers , before taking the latch pins high again.

( The first 8 bits will go right through the first register and out the far end to fill the second )

Only when you have filled all the registers do you want to latch the data to the outputs by taking the latch high again.

( and ignore the capacitor shown on the latch pin on the tutorial, it should not be there )

Hi Boffin,

I've just looked at the shiftOut tutorial again and rewired my breadboard just incase I made a mistake. I can confirm that it's all wired correctly, and don't worry, I haven't connected the capacitor :wink:

The code below is what I've just uploaded to the Arduino. Am I right in saying that only one LED should be lit? At the moment there are two lit - one on each shift register :roll_eyes:

int latchPin = 8;
int dataPin  = 11;
int clockPin = 12;

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

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

Thanks for the quick reply :slight_smile:

Youre only pushing one byte in, so next loop it is pushed through to the next register

try

int latchPin = 8;
int dataPin  = 11;
int clockPin = 12;

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {

  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, B00000001);
  shiftOut(dataPin, clockPin, MSBFIRST, B11111110);
  digitalWrite(latchPin, HIGH);
delay (1000);  // so you can see the results 

  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, B11111110);
  shiftOut(dataPin, clockPin, MSBFIRST, B00000001);
  digitalWrite(latchPin, HIGH);

delay (1000);  // so you can see the results 

}

(modified to swap display)

Hello again Boffin.

I can't believe I've struggled to understand this, the example you've given me makes perfect sense and it works. I actually feel a bit stupid now lol

Many thanks for your help :smiley:

glad to be able to help