# 3-digit 7 Segment counting from 000 to 999 - Shadow on Ones & Tens place

Hi guys. I need help on my program please.
I was able to make the 3-digit 7 segment led display count from 000 to 999, however I can’t seem to remove the “Shadow” its making while counting. The number the hundred’s place is displaying is being ‘shadowed’ to the ones and tens place…

IDK what is wrong, but im sure that there is. And do you guys know any other means to perform this task? I really need help

Here’s the code…

``````#include <LEDDisplay.h>

LEDDisplay *led;
LEDDisplay *hundred;
int millisecondsPerCount;
int counter;
unsigned long lastUpdate;

void setup()
{
millisecondsPerCount = 100;
int digitFlagPins[] = { 11, 10};
int digitFlagPins2[] = { 12, 12, 12 };
int segmentPins[] = {2, 3, 4, 5 ,6 ,7 ,8, 9};
int decimalPointPin = 9;
led = new LEDDisplay(3, digitFlagPins, segmentPins, decimalPointPin);
hundred = new LEDDisplay(3, digitFlagPins2, segmentPins, decimalPointPin);
Serial.begin(9600);
}

void loop()
{
unsigned long now = millis();
if (now - lastUpdate > millisecondsPerCount)
{
lastUpdate = now;
counter++;
// Serial.print(counter);
// Serial.print(" | ");
if (counter == 1000)
{
counter = 0;
}
}

int number = counter;
int hund = counter;

for(int i = 0; i < 2; i++)
{
led->displayNumber(number % 10, i);
delay(2);
number = number / 10 - hund/100;
Serial.println(hund/100);

for(int j = 0; j<3; j++)
{
hundred->displayNumber(hund/100, j);
}
}
}
``````

Images:

``````for(int i = 0; i < 2; i++)
{
led->displayNumber(number % 10, i);
delay(2);
number = number / 10 - hund/100;
Serial.println(hund/100);

for(int j = 0; j<3; j++)
{
hundred->displayNumber(hund/100, j);
}
}
``````

Did you mean for the j for loop to be inside the i for loop? Should the hundreds stuff even be in a for loop? That for loop prints the hundreds digit 3 times and you are using j as the digit to print to so it is doing it once on digit 0, then on 1, and then on 2.

Delta_G:

``````for(int i = 0; i < 2; i++)
``````

{
led->displayNumber(number % 10, i);
delay(2);
number = number / 10 - hund/100;
Serial.println(hund/100);

for(int j = 0; j<3; j++)
{
hundred->displayNumber(hund/100, j);
}
}

``````

Did you mean for the j for loop to be inside the i for loop? Should the hundreds stuff even be in a for loop? That for loop prints the hundreds digit 3 times and you are using j as the digit to print to so it is doing it once on digit 0, then on 1, and then on 2.
``````

How should I edit the code so that it doesn’t display on the ones & tens digit?
I have no idea how on what to change.

untested:

``````int hund = number / 100;
int tens = (number - (hund * 100)) / 10;
int ones = number % 10;
led->displayNumber(ones, 0);
led->displayNumber(tens, 1);
led->displayNumber(hundreds, 2);
``````

arduinodlb:
untested:

``````int hund = number / 100;
``````

int tens = (number - (hund * 100)) / 10;
int ones = number % 10;
led->displayNumber(ones, 0);
led->displayNumber(tens, 1);
led->displayNumber(hundreds, 2);

Sorry, but where do I put this code?

Hi,
Are you using current limit resistors in the segment connections.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom....

TomGeorge:
Hi,
Are you using current limit resistors in the segment connections.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom....

Yes sir. This is the schem I used, though the 7segment I used is the 4-digit ones.
I can post a video of what's happening when I try to run the circuit with my code.. Please help me, if it's not taking too much of your time.

lesliebrillantes:
Sorry, but where do I put this code?

Work through and understand what the code is doing, and it will be clear where to put it.

arduinodlb:

Work through and understand what the code is doing, and it will be clear where to put it.

It doesn't work.. all three 7 segments just went crazy, displaying random numbers.. it looks like all the numbers being displayed are just overlapping.

Well, the maths is correct, so the problem is something else. Did you look at the code and understand the maths?

Put a 1 second delay in your loop so you see what is actually happening.

I have never used the LED library you are using, so perhaps you are using it incorrectly.

It could also be a wiring problem.

Put some prints to the serial port in your loop so you can see what numbers are being sent to the LEDs.

And post your updated code here so that can be checked.

Could you also post a link to your LED library here? I can't seem to find one that corresponds to your usage.