Trouble on working with shift register 74HC595N

Hello!
I am having a problem when using shift register. I connected 16 Leds to Arduino through 2 shift registers. The Leds have to light up in rotation. I tried it in simulator (link: Tinkercad | From mind to design in minutes ), it works perfectly. But when I tried it in real, using hardware, there is something wrong with the second shift register. The Leds that connected to the second shift register do not light off or light up in rotation. They just continue stay lighted up.

With no program listed, its not easy to assist.
The last step should go something like this...
You will have to shift 16 bits out (2 x 8 bits) -
A being a value 0-255 and B 0-255
A should appear on shift reg 2, and B in shift reg 1

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST,a);// 8bits
shiftOut(dataPin, clockPin, MSBFIRST,b);//8bits
digitalWrite(latchPin, HIGH);

Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

Remember to add decoupling capacitors.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.

LarryD, I attached link for my project above, isn't it ok? Tinkercad | From mind to design in minutes

Rod5, yes, I did like that. Please, can you look at my project through linkthat I gave above. I will attach it again: Tinkercad | From mind to design in minutes

None of those links are working for me.
I think that you need a public link or a shared link. I don't know how to do that, it was never easy. I see a button "share" in the upper-right corner, that might produce a shared link.
I have a Tinkercad account and I am logged in.

share

And I didn't.
Some of us don't like forced sign-ups to Tinkercad, so your links don't reach everyone.
Leo..

If you want help here, post the code and schematic here. Making member register for Tinkercad in order to help you is going to limit the members that will help.

Read the forum guidelines to see how to properly post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Ok, I am attaching pictures of scheme from tinkercard.

And attaching code.

I repeat.

Koepel, I attached images.

Wawa, I attached images.

groundFungus, , I attached images.

Please go back and edit the post with the code to put the code in code tags. It is very simple. Highlihgt the code and click the </> in the toolbar above.

//#include <SoftwareReset.h>

//#include <SparkFunLIS3DH.h>


#include <Wire.h>
#include <SPI.h>

//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

int j = 0;
int mode = 0;
int blinkBtn = 4;
int waveBtn = 2;
int loopBtn = 3;
int masterSwitch = 5;
int blinkBtnState, waveBtnState, loopBtnState, masterState;
int speedPot = A0;
int speedValue = 0;
int master = 0;
//int buzzer = 9;
//LIS3DH myIMU;
int reset = 6;
//holders for infromation you're going to pass to shifting function
byte waveOne, waveTwo, waveThree, waveFour, waveFive, waveSix, waveSeven, loopOne, loopTwo, loopThree, loopFour, loopFive, loopSix, loopSeven;
byte waveDataOne[20], waveDataTwo[20], waveDataThree[20], waveDataFour[20], waveDataFive[20], waveDataSix[20], waveDataSeven[20];
byte loopDataOne[13], loopDataTwo[13], loopDataThree[13], loopDataFour[13], loopDataFive[13], loopDataSix[13], loopDataSeven[13];


void setup() {
  digitalWrite(reset, HIGH);
  delay(200);
  pinMode(reset, OUTPUT);

  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(blinkBtn, INPUT_PULLUP);
  pinMode(waveBtn, INPUT_PULLUP);
  pinMode(loopBtn, INPUT_PULLUP);
  //pinMode(buzzer, OUTPUT);
  pinMode(masterSwitch, INPUT_PULLUP);
  //myIMU.begin();
  Serial.begin(9600);
  MCUSR = 0;
  loopDataOne[0] = 1;
  loopDataOne[1] = 3;
  loopDataOne[2] = 6;
  loopDataOne[3] = 12;
  loopDataOne[4] = 24;
  loopDataOne[5] = 48;
  loopDataOne[6] = 96;
  loopDataOne[7] = 192;
  loopDataOne[8] = 128;
  loopDataOne[9] = 0;
  loopDataOne[10] = 0;
  loopDataOne[11] = 0;
  loopDataOne[12] = 0;

  loopDataTwo[0] = 4;
  loopDataTwo[1] = 12;
  loopDataTwo[2] = 24;
  loopDataTwo[3] = 48;
  loopDataTwo[4] = 96;
  loopDataTwo[5] = 192;
  loopDataTwo[6] = 128;
  loopDataTwo[7] = 0;
  loopDataTwo[8] = 1;
  loopDataTwo[9] = 3;
  loopDataTwo[10] = 2;
  loopDataTwo[11] = 0;
  loopDataTwo[12] = 0;

  loopDataThree[0] = 128;
  loopDataThree[1] = 192;
  loopDataThree[2] = 0;
  loopDataThree[3] = 0;
  loopDataThree[4] = 0;
  loopDataThree[5] = 0;
  loopDataThree[6] = 1;
  loopDataThree[7] = 3;
  loopDataThree[8] = 6;
  loopDataThree[9] = 12;
  loopDataThree[10] = 24;
  loopDataThree[11] = 48;
  loopDataThree[12] = 96;

  loopDataFour[0] = 0;
  loopDataFour[1] = 1;
  loopDataFour[2] = 3;
  loopDataFour[3] = 6;
  loopDataFour[4] = 12;
  loopDataFour[5] = 24;
  loopDataFour[6] = 48;
  loopDataFour[7] = 96;
  loopDataFour[8] = 192;
  loopDataFour[9] = 128;
  loopDataFour[10] = 0;
  loopDataFour[11] = 0;
  loopDataFour[12] = 0;

  loopDataFive[0] = 4;
  loopDataFive[1] = 12;
  loopDataFive[2] = 24;
  loopDataFive[3] = 48;
  loopDataFive[4] = 96;
  loopDataFive[5] = 192;
  loopDataFive[6] = 128;
  loopDataFive[7] = 0;
  loopDataFive[8] = 0;
  loopDataFive[9] = 1;
  loopDataFive[10] = 3;
  loopDataFive[11] = 2;
  loopDataFive[12] = 0;

  loopDataSix[0] = 16;
  loopDataSix[1] = 48;
  loopDataSix[2] = 96;
  loopDataSix[3] = 192;
  loopDataSix[4] = 128;
  loopDataSix[5] = 0;
  loopDataSix[6] = 3;
  loopDataSix[7] = 6;
  loopDataSix[8] = 12;
  loopDataSix[9] = 8;
  loopDataSix[10] = 0;
  loopDataSix[11] = 0;
  loopDataSix[12] = 0;

  loopDataSeven[0] = 0;
  loopDataSeven[1] = 0;
  loopDataSeven[2] = 0;
  loopDataSeven[3] = 0;
  loopDataSeven[4] = 1;
  loopDataSeven[5] = 2;
  loopDataSeven[6] = 4;
  loopDataSeven[7] = 8;
  loopDataSeven[8] = 24;
  loopDataSeven[9] = 48;
  loopDataSeven[10] = 32;
  loopDataSeven[11] = 64;
  loopDataSeven[12] = 128;

  waveDataOne[0] = 31;
  waveDataOne[1] = 63;
  waveDataOne[2] = 224;
  waveDataOne[3] = 192;
  waveDataOne[4] = 0;
  waveDataOne[5] = 0;
  waveDataOne[6] = 0;
  waveDataOne[7] = 0;
  waveDataOne[8] = 0;
  waveDataOne[9] = 0;
  waveDataOne[10] = 0;
  waveDataOne[11] = 0;
  waveDataOne[12] = 0;
  waveDataOne[13] = 0;
  waveDataOne[14] = 0;
  waveDataOne[15] = 0;
  waveDataOne[16] = 0;
  waveDataOne[17] = 0;
  waveDataOne[18] = 0;
  waveDataOne[19] = 0;

  waveDataTwo[0] = 0;
  waveDataTwo[1] = 2;
  waveDataTwo[2] = 3;
  waveDataTwo[3] = 125;
  waveDataTwo[4] = 252;
  waveDataTwo[5] = 128;
  waveDataTwo[6] = 0;
  waveDataTwo[7] = 0;
  waveDataTwo[8] = 0;
  waveDataTwo[9] = 0;
  waveDataTwo[10] = 0;
  waveDataTwo[11] = 0;
  waveDataTwo[12] = 0;
  waveDataTwo[13] = 0;
  waveDataTwo[14] = 0;
  waveDataTwo[15] = 0;
  waveDataTwo[16] = 0;
  waveDataTwo[17] = 0;
  waveDataTwo[18] = 0;
  waveDataTwo[19] = 0;

  waveDataThree[0] = 0;
  waveDataThree[1] = 0;
  waveDataThree[2] = 0;
  waveDataThree[3] = 0;
  waveDataThree[4] = 3;
  waveDataThree[5] = 127;
  waveDataThree[6] = 252;
  waveDataThree[7] = 128;
  waveDataThree[8] = 0;
  waveDataThree[9] = 0;
  waveDataThree[10] = 0;
  waveDataThree[11] = 0;
  waveDataThree[12] = 0;
  waveDataThree[13] = 0;
  waveDataThree[14] = 0;
  waveDataThree[15] = 0;
  waveDataThree[16] = 0;
  waveDataThree[17] = 0;
  waveDataThree[18] = 0;
  waveDataThree[19] = 0;

  waveDataFour[0] = 0;
  waveDataFour[1] = 0;
  waveDataFour[2] = 0;
  waveDataFour[3] = 0;
  waveDataFour[4] = 0;
  waveDataFour[5] = 0;
  waveDataFour[6] = 16;
  waveDataFour[7] = 57;
  waveDataFour[8] = 239;
  waveDataFour[9] = 198;
  waveDataFour[10] = 0;
  waveDataFour[11] = 0;
  waveDataFour[12] = 0;
  waveDataFour[13] = 0;
  waveDataFour[14] = 0;
  waveDataFour[15] = 0;
  waveDataFour[16] = 0;
  waveDataFour[17] = 0;
  waveDataFour[18] = 0;
  waveDataFour[19] = 0;

  waveDataFive[0] = 0;
  waveDataFive[1] = 0;
  waveDataFive[2] = 0;
  waveDataFive[3] = 0;
  waveDataFive[4] = 0;
  waveDataFive[5] = 0;
  waveDataFive[6] = 2;
  waveDataFive[7] = 3;
  waveDataFive[8] = 1;
  waveDataFive[9] = 28;
  waveDataFive[10] = 252;
  waveDataFive[11] = 224;
  waveDataFive[12] = 96;
  waveDataFive[13] = 0;
  waveDataFive[14] = 0;
  waveDataFive[15] = 0;
  waveDataFive[16] = 0;
  waveDataFive[17] = 0;
  waveDataFive[18] = 0;
  waveDataFive[19] = 0;

  waveDataSix[0] = 0;
  waveDataSix[1] = 0;
  waveDataSix[2] = 0;
  waveDataSix[3] = 0;
  waveDataSix[4] = 0;
  waveDataSix[5] = 0;
  waveDataSix[6] = 0;
  waveDataSix[7] = 0;
  waveDataSix[8] = 0;
  waveDataSix[9] = 0;
  waveDataSix[10] = 1;
  waveDataSix[11] = 15;
  waveDataSix[12] = 14;
  waveDataSix[13] = 0;
  waveDataSix[14] = 0;
  waveDataSix[15] = 240;
  waveDataSix[16] = 0;
  waveDataSix[17] = 0;
  waveDataSix[18] = 0;
  waveDataSix[19] = 0;


  waveDataSeven[0] = 0;
  waveDataSeven[1] = 0;
  waveDataSeven[2] = 0;
  waveDataSeven[3] = 0;
  waveDataSeven[4] = 0;
  waveDataSeven[5] = 0;
  waveDataSeven[6] = 0;
  waveDataSeven[7] = 0;
  waveDataSeven[8] = 0;
  waveDataSeven[9] = 0;
  waveDataSeven[10] = 0;
  waveDataSeven[11] = 0;
  waveDataSeven[12] = 0;
  waveDataSeven[13] = 0;
  waveDataSeven[14] = 56;
  waveDataSeven[15] = 1;
  waveDataSeven[16] = 6;
  waveDataSeven[17] = 64;
  waveDataSeven[18] = 128;
  waveDataSeven[19] = 0;


}

void loop() {
  //Read button states and analog value
  blinkBtnState = digitalRead(blinkBtn);
  waveBtnState = digitalRead(waveBtn);
  loopBtnState = digitalRead(loopBtn);
  masterState = digitalRead(masterSwitch);
  speedValue = analogRead(speedPot);
  Serial.println(speedValue);

  speedValue = speedValue / 3;
  //Serial.println(speedValue);
  //Prevents lights from flashing too fast to avoid epilepsy
  if (speedValue < 2)
    speedValue = 2;

  //Checks if button is clicked and then changes mode appropriately
  if (masterState == LOW)
  {
    master = 1;
  }
  else
  {
    master = 0;
    turnOff();
    digitalWrite(reset, LOW);
  }
  if (blinkBtnState == LOW)
  {
    mode = 1;
  }
  else if (waveBtnState == LOW)
  {
    mode = 2;
  }
  else if (loopBtnState == LOW)
  {
    mode = 3;
  }
  else
  {
    mode = 0;
  }

  ////Beeps at a certain frequency when enclosure is rotated too much
  //if(myIMU.readFloatAccelX() > 0.5 || myIMU.readFloatAccelX() < -0.5 || myIMU.readFloatAccelY() > 0.5 || myIMU.readFloatAccelY() < -0.5)
  //{
  //  tone(buzzer,350,100);
  //}

  //Runs led modes based on current mode
  if (mode == 1 && master == 1)
  {
    if (speedValue < 50)
      speedValue = 50;
    blinkLeds(speedValue);
  }
  else if (mode == 2 && master == 1)
  {
    colorWave(speedValue);
  }
  else if (mode == 3 && master == 1)
  {
    loopLetters(speedValue);
  }
  else
  {
    turnOff();
    digitalWrite(reset, LOW);
  }
}

//LEDs light up by columns, two at a time from left to right
void colorWave(int d)
{
  if (j == 20)
    j = 0;
  waveOne = waveDataOne[j];
  waveTwo = waveDataTwo[j];
  waveThree = waveDataThree[j];
  waveFour = waveDataFour[j];
  waveFive = waveDataFive[j];
  waveSix = waveDataSix[j];
  waveSeven = waveDataSeven[j];
  //ground latchPin and hold flow for as long as you are transmitting
  digitalWrite(latchPin, 0);
  //move 'em out
  shiftOut(dataPin, clockPin, waveSeven);
  shiftOut(dataPin, clockPin, waveSix);
  shiftOut(dataPin, clockPin, waveFive);
  shiftOut(dataPin, clockPin, waveFour);
  shiftOut(dataPin, clockPin, waveThree);
  shiftOut(dataPin, clockPin, waveTwo);
  shiftOut(dataPin, clockPin, waveOne);
  //return the latch pin high to signal chip that it
  //no longer needs to listen for information
  digitalWrite(latchPin, 1);
  j++;
  delay(d);
}

//LEDs make a trail and loop each letter individually
void loopLetters(int d)
{
  if (j == 13)
    j = 0;
  loopOne = loopDataOne[j];
  loopTwo = loopDataTwo[j];
  loopThree = loopDataThree[j];
  loopFour = loopDataFour[j];
  loopFive = loopDataFive[j];
  loopSix = loopDataSix[j];
  loopSeven = loopDataSeven[j];
  //ground latchPin and hold low for as long as you are transmitting
  digitalWrite(latchPin, 0);
  //move 'em out
  shiftOut(dataPin, clockPin, loopSeven);
  shiftOut(dataPin, clockPin, loopSix);
  shiftOut(dataPin, clockPin, loopFive);
  shiftOut(dataPin, clockPin, loopFour);
  shiftOut(dataPin, clockPin, loopThree);
  shiftOut(dataPin, clockPin, loopTwo);
  shiftOut(dataPin, clockPin, loopOne);
  //return the latch pin high to signal chip that it
  //no longer needs to listen for information
  digitalWrite(latchPin, 1);
  j++;
  delay(d);
}

void turnOff()
{
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
}

//blinks the whole register based on the number of times you want to
//blink "n" and the pause between them "d"
//starts with a moment of darkness to make sure the first blink
//has its full visual effect.
void blinkLeds(int d)
{
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  digitalWrite(latchPin, 1);
  delay(d);
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
  delay(d);
}

// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut)
{
  // This shifts 8 bits out MSB first,
  //on the rising edge of the clock,
  //clock idles low

  //internal function setup
  int i = 0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);

  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);

  //for each bit in the byte myDataOut�
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights.
  for (i = 7; i >= 0; i--)
  {
    digitalWrite(myClockPin, 0);

    //if the value passed to myDataOut and a bitmask result
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000
    // and proceeds to set pinState to 1.
    if ( myDataOut & (1 << i) )
    {
      pinState = 1;
    }
    else
    {
      pinState = 0;
    }

    //Sets the pin to HIGH or LOW depending on pinState
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }
  //stop shifting
  digitalWrite(myClockPin, 0);
}

Ok, I changed it.

Do you know "Wokwi", I like it more than Tinkercad. This is an example in Wokwi: https://wokwi.com/arduino/projects/301213976182653448. I found it on the Wokwi 74hc595 document page.

I think the connections in the Tinkercad simulation are okay. It should work in real life as well.

Sometimes breadboards have bad contacts and sometimes jumper wires are broken. Did you carefully check every connection ? and perhaps wiggle the wires ?
If no one else can see a problem, then you could show a photo of your project and maybe you have to remove the second shift register with all its wires and re-wire that again.

Its quite difficult to follow the wiring diagram - all same colours.
Try, swapping the two chips around - see if you still get the same results, just to check if the two 595's are still working fine.
check out