Led Display with a Shift Register

Hi. I'm new to Arduino and would like to understand better the shifting process with a 74HC595. I started a project with 2 shift registers, one quad led display and a couple of led's (the links are below) .One shift register is reserved for lighting 8 leds and the other for lighting the display with which led is pinned High in the exact moment : LED1, LED2 etc. ... but here is my problem: i can't make it work, the display part at least. I'm trying to display different numbers on my digits in the same time, like on digit one i want L, digit 2 E, digit 3 d, and digit 4 to change from 1 to 8. I can only get a single character display on all digits. My situation is similar to this guy here, the difference is i'm using a shift register:

http://forum.arduino.cc/index.php?topic=13442.0

My hardware connections for my quad display is the following:

-four digit pins i connect them to my Arduino board (4 slots-4 digits);
-my seven segments pins i connect them with the shift register, the last having also 3 wires connected to my arduino board (data, latch, clock);

Here's what i've got so far (only the display code for 2 digits, not with the leds for the moment):

int dataPin = A0; 
int clockPin = A2;
int latchPin = A1;

int DigitPins[] = {3, 4, 5, 6};
int SegFolosite[]={56,121,94,6,91,79,102,109,125,7,127};  // in ordine: L,E,d,1,2,3,4,5,6,7,8 

void setup() {
  
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);  
  pinMode(latchPin, OUTPUT);
  
  for (int digit=0;digit<4;digit++)   // daca nu e declarat, nu merg digitii !!!
   pinMode(DigitPins[digit], OUTPUT);
  

}

void loop() {
  
 /*  for(int i=0;i<11;i++){ 
      digitalWrite(latchPin, LOW);    // take the latchPin low so the LEDs don't change while you're sending in bits;
      shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[i]); // shift out the bits;
      digitalWrite(latchPin, HIGH);   //take the latch pin high so the LEDs will light up;
      delay(1000);  //freeze to view for a time what you've displayed
    }
 */
 
   digitalWrite(DigitPins[0],LOW);
   digitalWrite(DigitPins[1],HIGH);
   digitalWrite(DigitPins[2],HIGH);
   digitalWrite(DigitPins[3],HIGH);
   
   digitalWrite(latchPin, LOW);    // take the latchPin low so the LEDs don't change while you're sending in bits;
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[0]); // shift out the bits;
   digitalWrite(latchPin, HIGH);   //take the latch pin high so the LEDs will light up;
   delayMicroseconds(7000);
   
   digitalWrite(DigitPins[0],HIGH);
   digitalWrite(DigitPins[1],LOW);
   digitalWrite(DigitPins[2],HIGH);
   digitalWrite(DigitPins[3],HIGH);
   
   
   digitalWrite(latchPin, LOW);    // take the latchPin low so the LEDs don't change while you're sending in bits;
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[1]); // shift out the bits;
   digitalWrite(latchPin, HIGH);   //take the latch pin high so the LEDs will light up;
   delayMicroseconds(7000);
   
   
     
}

Led Display x4, common cathode : http://www.conexelectronic.ro/produs.php?id=135534
Shift Register: http://www.conexelectronic.ro/produs.php?id=42388
Arduino programming board: Intel® Galileo Gen 2 - DEV-13096 - SparkFun Electronics

Any code to understand a 4 digit display led connected to a shift register would be hepful. :frowning:

Do you have SRCLR on the 74HC595 connected to 5V?
Do you have OE/ on the 74HC595 connected to Gnd?
Do you have current limit resistors between the shift register output pins and the segment pins?
Need them sized so that the 4 DigitPins do not see more than ~30mA when all segments (and decimal point if used) are turned on, so about 4mA per segment.

SRCLR is connected to 5V.
OE is connected to GND.

I don't have resistors connected ! I'll try and see. May that solve my problem? Can you correct my code for a 3 digits displaying 3 different characters?

I can see numbers displaying if that is the case. But are 4 alike. Not different.

I think I would adjust it like so, turning off the prior digit before sending out the data for the next digit.

   digitalWrite(DigitPins[3],HIGH); // turn off layer 3

// send out layer 0 data   
   digitalWrite(latchPin, LOW);    // take the latchPin low so the LEDs don't change while you're sending in bits;
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[0]); // shift out the bits;
   digitalWrite(latchPin, HIGH);   //take the latch pin high so the LEDs will light up;
  digitalWrite(DigitPins[0],LOW);
   digitalWrite(DigitPins[1],HIGH);
   digitalWrite(DigitPins[2],HIGH);
   digitalWrite(DigitPins[3],HIGH);
   delayMicroseconds(7000);

      digitalWrite(DigitPins[0],HIGH); // turn off layer 0
// send out layer 1 data
   digitalWrite(latchPin, LOW);    // take the latchPin low so the LEDs don't change while you're sending in bits;
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[1]); // shift out the bits;
   digitalWrite(latchPin, HIGH);   //take the latch pin high so the LEDs will light up;

   digitalWrite(DigitPins[0],HIGH);
   digitalWrite(DigitPins[1],LOW);
   digitalWrite(DigitPins[2],HIGH);
   digitalWrite(DigitPins[3],HIGH);
   delayMicroseconds(7000);

      digitalWrite(DigitPins[1],HIGH); // turn off layer 1
// send out layer 2 data
   digitalWrite(latchPin, LOW);    // take the latchPin low so the LEDs don't change while you're sending in bits;
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[2]); // shift out the bits;
   digitalWrite(latchPin, HIGH);   //take the latch pin high so the LEDs will light up;

   digitalWrite(DigitPins[0],HIGH);
   digitalWrite(DigitPins[1],HIGH);
   digitalWrite(DigitPins[2],LOW);
   digitalWrite(DigitPins[3],HIGH);
   delayMicroseconds(7000);
      digitalWrite(DigitPins[2],HIGH); // turn off layer 2
// send out layer 3 data
   digitalWrite(latchPin, LOW);    // take the latchPin low so the LEDs don't change while you're sending in bits;
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[3]); // shift out the bits;
   digitalWrite(latchPin, HIGH);   //take the latch pin high so the LEDs will light up;

   digitalWrite(DigitPins[0],HIGH);
   digitalWrite(DigitPins[1],HIGH);
   digitalWrite(DigitPins[2],HIGH);
   digitalWrite(DigitPins[3],LOW);
delayMicroseconds(7000);

Ok, i'll let you know what happend after i rearrange the hardware. Another solution could be ussing de function millis() ? like trying to make each digit work independently. Correct me if i'm wrong. And thanks for the tips!

Thank you very much!! Now it seems it works very well, i can see LED1 on my 4 digits !!! and puting delay(1) works much more fine .

Was it the resistors? And your code, the prior digit part is interesting. If i take one single line out, the display is not flawless. Wonder if i can get another method and my fourth digit to change while the others stay the same.

for(int i=3;i<11;i++){   
   digitalWrite(DigitPins[3],HIGH); // turn off layer 3

   // send out layer 0 data   
   digitalWrite(latchPin, LOW);    
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[0]); 
   digitalWrite(latchPin, HIGH);   
   
   digitalWrite(DigitPins[0],LOW);
   digitalWrite(DigitPins[1],HIGH);
   digitalWrite(DigitPins[2],HIGH);
   digitalWrite(DigitPins[3],HIGH);
   delay(1);

   digitalWrite(DigitPins[0],HIGH); // turn off layer 0
   // send out layer 1 data
   digitalWrite(latchPin, LOW);    
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[1]); 
   digitalWrite(latchPin, HIGH);   

   digitalWrite(DigitPins[0],HIGH);
   digitalWrite(DigitPins[1],LOW);
   digitalWrite(DigitPins[2],HIGH);
   digitalWrite(DigitPins[3],HIGH);
   delay(1);

   digitalWrite(DigitPins[1],HIGH); // turn off layer 1
   // send out layer 2 data
   digitalWrite(latchPin, LOW);    
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[2]); 
   digitalWrite(latchPin, HIGH);   

   digitalWrite(DigitPins[0],HIGH);
   digitalWrite(DigitPins[1],HIGH);
   digitalWrite(DigitPins[2],LOW);
   digitalWrite(DigitPins[3],HIGH);
   delay(1);
   
   
   digitalWrite(DigitPins[2],HIGH); // turn off layer 2
   // send out layer 3 data
   
   digitalWrite(latchPin, LOW);   
   shiftOut(dataPin, clockPin, MSBFIRST, SegFolosite[i]); 
   digitalWrite(latchPin, HIGH);   
   digitalWrite(DigitPins[0],HIGH);
   digitalWrite(DigitPins[1],HIGH);
   digitalWrite(DigitPins[2],HIGH);
   digitalWrite(DigitPins[3],LOW);
   delay(1);
}

i put a for(). the fourth digit changes like i want, but very fast. a delay can't help because it shuts down the other leds >:( annoying