# Why don't both digits display at same time? [SOLVED]

This code is not meant to keep time so please ignore any references to hours.

My problem is that the segments 1-9 display perfectly. When the counter gets to 10, however, the "0" will display for about a second, then turns off as the "1" turns on. A second later, the "1" (in the tens column) turns off and the "1" in the ones column displays until the "1" in the tens column comes on. This cycle continues until the counter resets to "1" at which time, all the numbers between 1 and 9 display correctly.

int DS_14 = 3; int STCP_12 = 7; int SHCP_11 = 4;

int Hr1 = 0; // ten digit for hours int Hr2 = 1; // one digit for hours

int digit1 = 5; // tens digit for hours (HR1) int digit2 = 6; // one digit for hours (Hr2)

int Digit[10] = {64, 121, 36, 48, 25, 18, 2, 120, 0, 24};

void setup() { pinMode(STCP_12, OUTPUT); pinMode(DS_14, OUTPUT); pinMode(SHCP_11, OUTPUT); pinMode(digit1, OUTPUT); pinMode(digit2, OUTPUT); Serial.begin(9600); } void loop() { HrDisp(); delay(1000); }

void HrDisp() { //Displays the hour

Hr2++;

display1(); if (Hr2 == 10) { // Reset to 0 after counting for 9 hours. Hr2 = 0; Hr1++; } if (Hr1 == 1 and Hr2 == 3) { //13:00 becomes 1:00 Hr1 = 0; // Resets hours ten digit to 0 Hr2 = 1; } digitalWrite(STCP_12, LOW); shiftOut(DS_14, SHCP_11, MSBFIRST, Digit[Hr2]); digitalWrite(STCP_12, HIGH); delay(5); if (Hr1 != 0) { display2(); digitalWrite(STCP_12, LOW); shiftOut(DS_14, SHCP_11, MSBFIRST, Digit[Hr1]); digitalWrite(STCP_12, HIGH); delay(5); } } void display1() { digitalWrite(digit1, 1); digitalWrite(digit2, 0); } void display2() { digitalWrite(digit1, 0); digitalWrite(digit2, 1); }

/// END ///

Michael

Hello Michael,

Especially item #7 on posting code, then go back and edit your post to use code tags </> as per the instructions.

To stand any chance of helping you we need to at least know what kind of display you have and how you have it wired, so please post a schematic and information about the display.
How to post an image

Also, the pin and variable names in your code might mean something to you but they mean nothing to me and I suspect nothing to anyone else.

I realise you are fairly new here but after 11 posts I have thought you’d know this by now.

Thank you.

The OP’s issue is clearly a problem with multiplexing. To be more specific, the code for multiplexing the display does not play well with the `delay(1000)` in `loop()`.

Moderator edit: hollow off-topic whinging removed

Thank you, PerryBebbington, for your polite admonishment of my post. I will attempt to do better next time. I did not include the schematic as the circuit worked for numbers 1-9. I felt the issue was with the multiplexing as odometer suggested.

I very much appreciate all time you experienced guys (and gals) give to helping us newbies learn to use this remarkable technology.

Michael

Thank you, odometer!