4 digit 7 segment LED : digits echoes to next digit

I have setup a very simple simple project

I use a simple 4 digit 7 segments led display on a breadboard, and I use to read a value from a potentiometer.

Everything works reasonably well.

But, for some reason, the value printed on a digit "echoes" to the digit on its right... (the one on the extreme right, echo on the first one from the left)

I can't figure out why. How can I get 4 clear digits?

see pic :

code is here :

wiring :

https://create.arduino.cc/projecthub/SAnwandter1/programming-4-digit-7-segment-led-display-2d33f8
https://halckemy.s3.amazonaws.com/uploads/attachments/261205/4_digit_7_segment_display_connections_KaSuFbbPfq.jpg

I included functions to strip leading zeros, and convert the 0-1024 values from the potentiometer to a simple (and stable) 0-9 single digit value.

Any help appreciated.

Phil

With the setLed(led); you switch to the next digit. After that you decide how to set the segments wich takes some time and the old segmet-setting starts to glow.

What you need to do:

  1. Turn off all digits
  2. Decide/set the segments
  3. Turn the right digit on

As Rintin says. I think it's officially called "ghosting".

filip_canada:
wiring :
https://www.arduino.cc/en/tutorial/AnalogInput
Programming 4 Digit 7 Segment LED Display | Arduino Project Hub
https://halckemy.s3.amazonaws.com/uploads/attachments/261205/4_digit_7_segment_display_connections_KaSuFbbPfq.jpg

Phil, that circuit will damage your Arduino, and possibly the display as well. If you want to know why, or how to avoid the damage, just ask.