Pages: [1]   Go Down
Author Topic: [SOLVED] Two Or More 74HC595 SR's On Uno  (Read 682 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone smiley

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
« Last Edit: February 16, 2013, 04:33:47 pm by Cosmic-Wizard » Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1222
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 )
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-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 smiley-roll

Code:
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 smiley
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1222
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

try

Code:
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)
« Last Edit: February 16, 2013, 02:46:45 am by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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-grin
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1222
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

glad to be able to help
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Pages: [1]   Go Up
Jump to: