2

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

gre_gor
  • 1,682
  • 4
  • 18
  • 28
Mosh Feu
  • 133
  • 1
  • 7

2 Answers2

5

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).

enter image description here

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.

VE7JRO
  • 2,515
  • 19
  • 27
  • 29
1

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.

Michel Keijzers
  • 13,014
  • 7
  • 41
  • 58