# Problem with a seven segment display. The segments blink then turn off

I can't figure it out what is the problem with my circuit, the segments turning on for sec and then they are turning off for good.

I tried to connect to GND instead of the 5 V but then, nothing happened.

My code:

``````void setup() {
for (int pin = 2 ; pin < 9 ; pin++){ // setup pins 2 – 8 to be output
pinMode(pin, OUTPUT);
}

for (int pin = 2 ; pin < 9 ; pin++){ // turn on pins 2 - 8
digitalWrite(pin, HIGH);
}
}

void loop(){}
``````

Working simulation demo

• How do you expect a LED to light up if you put 5 V on anode and cathode? Commented Mar 15, 2018 at 17:22
• You are also missing the current limiting resistors. Commented Mar 15, 2018 at 17:24
• @gre_gor. Thanks. I updated my question. Can you take a look? Commented Mar 15, 2018 at 17:37
• There are two types of 7 segment displays: common anode and common cathode. Which do you have? Depending on the type, you must connect the COM pin to 5V and all the segment pins via a resistor to GND to light them up (common anode type). Else reversed (COM to GND, segments to +5V over a resistor) Commented Mar 15, 2018 at 18:29

The first thing to understand is how to connect the 7 segment display to your Arduino. The common anode pin connects directly to 5VDC. Each "segment" connects to the Arduino through a current limiting resistor (1k ohm is a good value to start with).

To turn a segment on, you supply a ground to it (through the resistor of course). Change: digitalWrite(pin, HIGH) to: digitalWrite(pin, LOW) in your sketch to turn on the segments.

I'm sure there are plenty of tutorials on the internet showing one resistor on the common anode input, but that is not the correct way to drive the display. Think about what happens when you display the number 1 VS the number 8. Changing the number of segments drawing power from the single resistor will vary the intensity of the display. The number 1 will be far brighter than the number 8.

• Make sence. You are right, all of the tutorials are using only 1 resistor. I will try it.. Thanks! Commented Mar 15, 2018 at 20:04
• There are two reasons the tutorials might show a single resistor on the common cathode or anode: (1) They just accept the fact that an 8 will be a little dimmer than a 1--that might be acceptable for a quick hack. (2) They illuminate one segment at a time, essentially blinking the segments fast enough that they seem to be lit steadily, which you can do from the microcontroller if it's not too busy doing other work. There are also peripheral drivers that can do this type of time multiplexing. Commented Mar 15, 2018 at 21:55
• Thanks! It was a good explanation! Another thing I noticed that there are 2 types of 7 segment display based on Anode and Cathode. Depends on the type I need to connect it to 5v / GND. Right? Commented Mar 17, 2018 at 19:42
• @MoshFeu - Yes, there are common anode and common cathode displays available. Here is a tutorial that does a good job of explaining the differences: electronics-tutorials.ws/blog/7-segment-display-tutorial.html Commented Mar 17, 2018 at 20:00

With foregood you mean broken probably.

I don't see any resistor in your circuit, probably the LEDs are broken.

I'm afraid you have to use a new segment LED, and follow:

Arduino Example