Go Down

Topic: Two 74HC595 shift regesters (Read 160 times) previous topic - next topic

Dennisdr1953

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() {


 
  digitalWrite(latchPin,LOW);
  shiftOut(dataPin, clockPin,LSBFIRST, LEDs);
  digitalWrite(latchPin,HIGH);
  delay(dtrg);

Any help would be welcome.

dennisdr1953@gmail.com
   
   

 
}

dougp

Sounds like the registers are not in a cascade configuration - Arduino feeds 1st register, 1st register feeds 2nd register.
I don't trust atoms.  They make up everything.

No private consultations undertaken!

TomGeorge

#2
Feb 25, 2020, 07:22 am Last Edit: Feb 25, 2020, 07:22 am by TomGeorge
Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
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.

https://www.arduino.cc/en/tutorial/ShiftOut

Tom.... :)



Everything runs on smoke, let the smoke out, it stops running....

JCA34F

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

pwillard

#4
Feb 25, 2020, 01:34 pm Last Edit: Feb 25, 2020, 01:35 pm by pwillard
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.

herbschwarz

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

Go Up