H/M/S Clock multiplexing 6 7-Segments displays issues

i’m kinda new on arduino world… i need some help please :slight_smile:

i have to do a digital clock with arduino using only 7 digital outputs and NO SHIFT REGISTERS and i solved the problem but i can’t get any idea on how to make the code.
this is just the part of the clock where i write the numbers on the displays with the Decoder 74ls48 and a have 3 more outputs that i can use that i put on a DEMUX 74ls138… i don’t know how to turn on the different displays with the binary code on the DEMUX
As attachement i put the electric circuit

 for (ora2=0;ora2<3;ora2++){
    digitalWrite(A, ora2%2);
    digitalWrite(B, (ora2/2)%2);
    digitalWrite(C, (ora2/4)%2);
    digitalWrite(D, (ora2/8)%2);
    for (ora1=0;ora1<4;ora1++){
      digitalWrite(A, ora1%2);
      digitalWrite(B, (ora1/2)%2);
      digitalWrite(C, (ora1/4)%2);
      digitalWrite(D, (ora1/8)%2);
      for (min2=0;min2<6;min2++){
        digitalWrite(A, min2%2);
        digitalWrite(B, (min2/2)%2);
        digitalWrite(C, (min2/4)%2);
        digitalWrite(D, (min2/8)%2);
        for (min1=0;min1<10;min1++){
          digitalWrite(A, min1%2);
          digitalWrite(B, (min1/2)%2);
          digitalWrite(C, (min1/4)%2);
          digitalWrite(D, (min1/8)%2);
          for (sec2=0;sec2<6;sec2++){
            digitalWrite(A, sec2%2);
            digitalWrite(B, (sec2/2)%2);
            digitalWrite(C, (sec2/4)%2);
            digitalWrite(D, (sec2/8)%2);
            for (sec1=0;sec1<10;sec1++) {
              digitalWrite(A, sec1%2);
              digitalWrite(B, (sec1/2)%2);
              digitalWrite(C, (sec1/4)%2);
              digitalWrite(D, (sec1/8)%2);
              delay(10);
              Serial.print(ora2);
              Serial.print(ora1);
              Serial.print(" : ");
              Serial.print(min2);
              Serial.print(min1);
              Serial.print("    ");
              Serial.print(sec2);
              Serial.println(sec1);
            }
          }
        }
      }
    }
  }

Circuito_Elettrico.pdf (39.5 KB)

You can’t use a MAX7219? Then only need 3 pins and 1 chip.
It does the multiplexing for you.
Your way, driving anodes high with 1 chip, drive common cathode low with ULN2803, cycle thru all 6 displays, that can work too.
You don’t have the right chips selected yet.
'138 for example has the selected output going low - you need just 1 high.
74LS48 seems like the right chip for driving anodes.

i know the thing of the level low and on the circuit i put a not gate before all darlington gates i can use only this thing nothin' else :( it's a school thing... and i had only this idea and my teacher said it's ok... now i need the code and i don't know what to do... :(

EDIT i can only use the common catode display.

I like to keep the multiplexing simpler. Use blink without delay and array, and variable for each digit stored in an array:

void loop(){
currentMillis = millis();  // all time related elements are declared as unsigned long
elapsedMillis1= currentMillis - previousMillis1;
if (elapsedMillis1 >=fivemS){ // ~30 Hz refresh rate (1/30/6 = 5.56mS ontime per digit)
previousMillis1 = previousMillis1 + fiveMs;
digitCount = digitCount +1;
if (digitCount == 6){digitCount = 0;}
// output data for anode pins from anodeArray[digitCount]
// where anodeArray[0] = tensHours,
// where anodeArray[1] = onesHours,
// where anodeArray[2] = tensMinutes,
// where anodeArray[3] = onesMinutes,
// where anodeArray[4] = tensSeconds,
// where anodeArray[5] = onesSeconds,

// output cathode data based on digitCount, could be an array also

} // end multiplex time check

// keep track of time similarly
elapsedMillis2= currentMillis - previousMillis2;
if (elapsedMillis2 >=oneSec){ // ~30 Hz refresh rate (1/30/6 = 5.56mS ontime per digit)
previousMillis2 = previousMillis2 + oneSec;
// update the time bytes above
oneSeconds = oneSeconds +1;
if (onesSeconds == 10){
onesSeconds = 0;
tensSeconds = tensSeconds +1;
if (tensSeconds == 6){
tensSeconds = 0;
oneMinutes = onesMinute+1;
// etc incrementing & rolling over the time elements as needed; up to 11:59:59, then 00:00:00
}
} // end one second updates

// other stuff  you may be doing

) // end loop

yeah.... but :blush: this is too far for me :D as i said i can only use that components

So you can't write your own code even? Good luck with that.