0

I have now successfully learned how to control a single 8 bit shift register 74HC595 with Arduino UNO but whenever I tried to connect another one with the first shift resistor via cascading connection just like the image shown below (well I didn't use the 10uf capacitor between positive and negative terminal), the first shift register only outputs as desired but the second shift register, connected to a cascading connection, does not seem to work...

enter image description here

Here is the code.

    int latchPin = 10;  // Latch pin of 74HC595 is connected to Digital pin 5
int clockPin = 11;  // Clock pin of 74HC595 is connected to Digital pin 6
int dataPin = 9;    // Data pin of 74HC595 is connected to Digital pin 4

byte leds = 0;      // Variable to hold the pattern of which LEDs are currently turned on or off

/*
 * setup() - this function runs once when you turn your Arduino on
 * We initialize the serial connection with the computer
 */
void setup() 
{
  // Set all the pins of 74HC595 as OUTPUT
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
  Serial.begin(9600);
}

/*
 * loop() - this function runs over and over again
 */
void loop() 
{
  leds = 0; // Initially turns all the LEDs off, by giving the variable 'leds' the value 0
  updateShiftRegister();
  delay(500);
  for (int i = 0; i <= 16; i++) // Turn all the LEDs ON one by one. 
  {
    bitSet(leds, i);        // Set the bit that controls that LED in the variable 'leds'
    updateShiftRegister();
    delay(500);
  }
  
 /* The loop above should repeated 16 times as there are 2 shift resistors, each of them containing 8 and we need to lit up all 16 LEDs*/ 
  
}

/*
 * updateShiftRegister() - This function sets the latchPin to low, then calls the Arduino function 'shiftOut' to shift out contents of variable 'leds' in the shift register before putting the 'latchPin' high again.
 */
void updateShiftRegister()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);
   digitalWrite(latchPin, HIGH);
}

so is it my code or wiring problem?

I have read many articles on internet to make myself get it understood but unfortunately, none of the articles satisfied me.

many thanks for giving me a bit of your precious time...

7
  • connect the microcontroller output to the second 74HC595 to test it
    – jsotola
    Dec 2 '20 at 5:50
  • add a second shiftOut. one sends only 8 bits. arduino.cc/reference/en/language/functions/advanced-io/shiftout
    – Juraj
    Dec 2 '20 at 5:56
  • someone please post a code, I really am unable to understand what to do, even after reading the article link by @Juraj, i have got a new mess inside my brain Dec 2 '20 at 6:08
  • 1
    add leds2 and send it before leds
    – Juraj
    Dec 2 '20 at 6:12
  • 1
    Oh, getting to understand it a little, i have to create another byte data type named 'led2' for the second shift register then repeat the same process? Right? Dec 2 '20 at 8:33
0

I am really very sorry to say that after a long inspection , i have found that

shift register clear (pin 10) pin of the second shift register remained inactivated due to loose connection of power, after fixing it, all shift registers are working very fine.

I do really apologize to all those friends who came to help me, for wasting their time, i am really very sorry for that...

all problems are solved now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.