viejo led numeral de reloj alarma radio

Bueno les dejo una foto del led, lo estuve programando , y viendo como funciona, su funcionamiento es tener 2 o 4 tierras, y prender los led por separado. Dependiendo que tierra activas se activa un diferente led, por eso el codigo tiene tierras conectadas a los pines digitales 8 y 9 del arduino. Les dejo una foto, cualquier cosa pregunte

//programa para led 
//aca declaramos los pines del led, con los pines digitales del arduino

const int pin21 = 22;
const int pin20 = 23;
const int pin19 = 24;
const int pin18 = 25;
const int pin17 = 26;
const int pin16 = 27;
const int pin15 = 28;

//declaramos las tierras por ahora son 2, pero tienen 3 o 4 estos leds
const int tierra1pin1 = 8;
const int tierra2Pin2 = 9;


void setup() {
  pinMode(pin21, OUTPUT);
  pinMode(pin20, OUTPUT);
  pinMode(pin19, OUTPUT);
  pinMode(pin18, OUTPUT);
  pinMode(pin17, OUTPUT);
  pinMode(pin16, OUTPUT);
  pinMode(pin15, OUTPUT);


  pinMode(tierra1pin1, OUTPUT);
  pinMode(tierra2Pin2, OUTPUT);
  
}


void loop() {


Num2LedNum3();
Num3LedNum4();

}  

//cada le de escribe por separado, y variando las dos tierras, que tiene el led
//variamos las tierras con un low y un high, dependiendo que queremos activar

void Num0LedNum4(){
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin18, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin21, LOW);
  digitalWrite(pin18, LOW);
  //cambiamos de tierra
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin21, LOW);
  digitalWrite(pin19, LOW);
}

void Num1LedNum4(){
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin19, LOW);
  digitalWrite(pin20, LOW);
}


void Num2LedNum4(){
  //ponemos la tierra para 3 primeros led que se van a encender

  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin18, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin18, LOW);
  digitalWrite(pin19, LOW);

  //canbiamos de tierra para que cambien los leds encendidos
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin21, LOW);
  digitalWrite(pin19, LOW);
}

void Num3LedNum4(){

  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin19, LOW);

  //cambiamos de tierra
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin19, LOW);
  digitalWrite(pin20, LOW);
  digitalWrite(pin21, LOW);
}

void Num4LedNum4(){
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);

  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin19, LOW);
  digitalWrite(pin20, LOW);

  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin19, LOW);
  digitalWrite(pin21, LOW);
}

void Num5LedNum4(){
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin19, LOW);
  digitalWrite(pin21, LOW);

  //cambiamos de tierra
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin21, LOW);
 
}

void Num6LedNum4(){
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin18, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin19, LOW);
  digitalWrite(pin21, LOW);
  digitalWrite(pin18, LOW);
  //cambiamos de tierra
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin21, LOW);
}

void Num7LedNum4(){
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin21, HIGH);

}

void Num8LedNum4(){
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin18, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin19, LOW);
  digitalWrite(pin21, LOW);
  digitalWrite(pin18, LOW);
  //cambiamos de tierra
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin21, LOW);
  digitalWrite(pin19, LOW);
}

void Num9LedNum4(){
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin19, LOW);
  digitalWrite(pin21, LOW);
  
  //cambiamos de tierra
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin20, HIGH);
  digitalWrite(pin21, HIGH);
  digitalWrite(pin19, HIGH);
  digitalWrite(pin20, LOW);
  digitalWrite(pin21, LOW);
  digitalWrite(pin19, LOW);

}

//numeros del 3 digito del display 
void Num0LedNum3(){
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin17, HIGH);
  digitalWrite(pin16, HIGH);
  digitalWrite(pin15, HIGH);
  digitalWrite(pin15, LOW);
  digitalWrite(pin16, LOW);
  digitalWrite(pin17, LOW);
  //cambiamos de tierra
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin18, HIGH);
  digitalWrite(pin17, HIGH);
  digitalWrite(pin15, HIGH);
  digitalWrite(pin15, LOW);
  digitalWrite(pin17, LOW);
  digitalWrite(pin18, LOW);
}

void Num1LedNum3(){
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin17, HIGH);
  digitalWrite(pin16, HIGH); 
  digitalWrite(pin17, LOW);
  digitalWrite(pin16, LOW);
}

void Num2LedNum3(){
  //ponemos la tierra para 3 primeros led que se van a encender

  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin16, HIGH);
  digitalWrite(pin15, HIGH);
  digitalWrite(pin16, LOW);
  digitalWrite(pin15, LOW);

  //canbiamos de tierra para que cambien los leds encendidos
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin18, HIGH);
  digitalWrite(pin17, HIGH);
  digitalWrite(pin16, HIGH);
  digitalWrite(pin18, LOW);
  digitalWrite(pin17, LOW);
  digitalWrite(pin16, LOW);
}

void Num3LedNum3(){

  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);
  digitalWrite(pin15, HIGH);
  digitalWrite(pin16, HIGH);
  digitalWrite(pin17, HIGH);
  digitalWrite(pin15, LOW);
  digitalWrite(pin16, LOW);
  digitalWrite(pin17, LOW);

  //cambiamos de tierra
  digitalWrite(tierra1pin1, HIGH);
  digitalWrite(tierra2Pin2, LOW);
  digitalWrite(pin17, HIGH);
  digitalWrite(pin16, HIGH);
  digitalWrite(pin17, LOW);
  digitalWrite(pin16, LOW);
}

void Num4LedNum3(){
//tierra 1
digitalWrite(tierra1pin1, LOW);
digitalWrite(tierra2Pin2, HIGH);
digitalWrite(pin17, HIGH);
digitalWrite(pin16, HIGH);
    
//cambiamos a tierra 2
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, HIGH);

}
void clearLEDs(){
  digitalWrite( pin15, LOW);
  digitalWrite( pin16, LOW);
  digitalWrite( pin17, LOW);
  digitalWrite( pin18, LOW);
  digitalWrite( pin19, LOW);
  digitalWrite( pin20, LOW);
  digitalWrite( pin21, LOW);
  digitalWrite(tierra1pin1, LOW);
  digitalWrite(tierra2Pin2, LOW);
  
}



// }