Stacked 8 74HC595 flicker and output problem.

I’m now currently working on a project that has 64 bit output. Here’s the code

char command;
String string,strval[8];
boolean ledon = false;

int val[8];
//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 12;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 11; 
  void setup()
    pinMode(latchPin, OUTPUT);
    pinMode(dataPin, OUTPUT);  
    pinMode(clockPin, OUTPUT);

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

  void loop()
if (Serial.available() > 0) 
{string = "";}
    int k=0;
    while(Serial.available() > 0)
      command = ((byte);
      if(command == ';')
        string += command;
int j=0;

for(int i=0;i<8;i++){
for(int i=0;i<string.length();i++){
  char c=string[i];
    else {strval[j]+=c;} 
for(int i=0;i<8;i++){

digitalWrite(latchPin, LOW);

   // shift out the bits:
for(int i=7;i>=0;i--){  
 shiftOut(dataPin, clockPin,MSBFIRST, val[i]);
digitalWrite(latchPin, HIGH);


The input is a string that has 8 decimals separated by the symbol “|” and marked by “;” for the prog to know it is the last character. I’ve tested this separation and putting the values into an array and it works fine.

Although when I combine this with the shiftout code, the output is different than expected. I’ve tried using the code, which basically is: latchpin on, shift the data, latch pin out, separately and it’s fine. but when I use it one this. it doesn’t work.

The setup and schematic i used is based on this

I have 4 modules of this shiftout

one module is like this (from the same arduino page link)

I’m really stucked here. Thanks guys, I hope you can help.

First things first, don't use the the capacitor on ST_CP

Next do you have a decoupling capacitor ( .1uf ) close the each power pin on each I.C. ?