user43379: 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

user31105: 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
Especially read this fragment:
Current-limiting Resistors

Don't forget that the display uses LEDs, so you should use
  current-limiting resistors in series with the digit pins. 330 ohms is
  a safe value if you're unsure. If you use current-limiting resistors
  on the segment pins instead, then open up the SevSeg.h file and set
  RESISTORS_ON_SEGMENTS to 1 for optimal brightness.


user37523: 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.

43379: <p>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.</p>

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

<p><a href="https://i.stack.imgur.com/rCOCX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rCOCX.png" alt=""></a></p>

<p>My code:</p>

<pre class="lang-c++ prettyprint-override"><code>void setup() {  
  for (int pin = 2 ; pin &lt; 9 ; pin++){ // setup pins 2 – 8 to be output   
    pinMode(pin, OUTPUT);
  }   

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

void loop(){}
</code></pre>

<p><a href="https://www.tinkercad.com/things/bzFECN3pcfE-cool-tumelo" rel="nofollow noreferrer">Working simulation demo</a></p>
 31105: <p>With foregood you mean broken probably.</p>

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

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

<p><a href="http://playground.arduino.cc/Main/SevenSegmentLibrary" rel="nofollow noreferrer">Arduino Example</a></p>

<p>Especially read this fragment:</p>

<p>Current-limiting Resistors</p>

<blockquote>
  <p>Don't forget that the display uses LEDs, so you should use
  current-limiting resistors in series with the digit pins. 330 ohms is
  a safe value if you're unsure. If you use current-limiting resistors
  on the segment pins instead, then open up the SevSeg.h file and set
  RESISTORS_ON_SEGMENTS to 1 for optimal brightness.</p>
</blockquote>
 37523: <p>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).</p>

<p><a href="https://i.stack.imgur.com/OGcAW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OGcAW.png" alt="enter image description here"></a></p>

<p>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.</p>

<p>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.</p>
