tripple 7-segment digit @ arduino mega 2560

Hi everybody,

I've wired up a tripple 7-segment LED-digit (EVERLIGHT ELT-541SYGWA/S530-E2/R, Datasheet: ELT-541SYGWA/S530-E2/R pdf, ELT-541SYGWA/S530-E2/R Description, ELT-541SYGWA/S530-E2/R Datasheet, ELT-541SYGWA/S530-E2/R view ::: ALLDATASHEET :::) via one 74HC595N IC to my Arduino Mega 2560 Rev3 and am trying to display numbers using the following code, however, each digit shows the value of the first digit:

#define DIGIT_CLOCK 41
#define DIGIT_LATCH 42
#define DIGIT1_SERDATA 43

int numbers[11] = {119, 36, 107, 110, 60, 94, 95, 100, 127, 126, 128}; // 0...9 + DP

void setup() {
  pinMode(DIGIT_LATCH, OUTPUT);
  pinMode(DIGIT_CLOCK, OUTPUT);
  pinMode(DIGIT_SERDATA, OUTPUT);
}

void loop() {
 delay(2000);
 displayNumber(1,2,3);
 delay(1000);
 displayNumber(-1,-1,-1);
}

void displayNumber(int third, int second, int first){

    digitalWrite(DIGIT_LATCH, LOW);

    if (first >= 0) {
    shiftOut(DIGIT_SERDATA, DIGIT_CLOCK, MSBFIRST, 0);
    } else {
    shiftOut(DIGIT_SERDATA, DIGIT_CLOCK, MSBFIRST, numbers[first]);
    }
    if (second >= 0) {
    shiftOut(DIGIT_SERDATA, DIGIT_CLOCK, MSBFIRST, numbers[second]);
    } else {
    shiftOut(DIGIT_SERDATA, DIGIT_CLOCK, MSBFIRST, 0);
    }
    if (third >= 0) {
    shiftOut(DIGIT_SERDATA, DIGIT_CLOCK, MSBFIRST, numbers[third]);
    } else {
    shiftOut(DIGIT_SERDATA, DIGIT_CLOCK, MSBFIRST, 0);
    }

    digitalWrite(DIGIT_LATCH, HIGH);

}

What did I miss?

Cheers,
Tobias

I can't follow that code.
Try this function:-

void display(int number)
{
  static byte sevenCode[10] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67 };
  if(number > 999) number = number % 1000;
   int hundreds = number / 100;
   int tens = (number / 10) % 10;
   int units = number - (hundreds * 100) - (tens * 10);
   shiftOut(SERINPin, SRCKPin, MSBFIRST, sevenCode[units]);
   if( number > 9 ) // leading zero suppression
      shiftOut(SERINPin, SRCKPin, MSBFIRST, sevenCode[tens]);
      else
      shiftOut(SERINPin, SRCKPin, MSBFIRST, 0);
   
   if( number > 99)  // leading zero suppression 
      shiftOut(SERINPin, SRCKPin, MSBFIRST, sevenCode[hundreds]);
      else
      shiftOut(SERINPin, SRCKPin, MSBFIRST, 0);
   digitalWrite(RCKPin, HIGH); // and latch
   digitalWrite(RCKPin, LOW);

}

I tried that code, however the result is similar: the second digit is displayed across all three digits.

That is working code.
If that is not working then you have some wiring wrong.