- Use the code-tag
- I don't see that you have code for the zero
- You repeat the same code over and over again. Maybe you want to move some to functions and/or use lookup tables
digitalWrite(D1, HIGH);
digitalWrite(D2, LOW);
digitalWrite(D3, LOW);
digitalWrite(D4, LOW);
// At this point you have activated the new digit, but the segments are the old values.
// This will cause ghosting.
digitalWrite(pinA, HIGH);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, HIGH);
digitalWrite(pinE, HIGH);
digitalWrite(pinF, HIGH);
digitalWrite(pinG, HIGH);
break;
You need something like this:
allDigitsOff();
setSegments();
activateDigit();