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

  • 1
    How do you expect a LED to light up if you put 5 V on anode and cathode? – gre_gor Mar 15 '18 at 17:22
  • You are also missing the current limiting resistors. – gre_gor Mar 15 '18 at 17:24
  • @gre_gor. Thanks. I updated my question. Can you take a look? – Mosh Feu Mar 15 '18 at 17:37
  • 3
    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) – Maximilian Gerhardt Mar 15 '18 at 18:29
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.

  • Make sence. You are right, all of the tutorials are using only 1 resistor. I will try it.. Thanks! – Mosh Feu Mar 15 '18 at 20:04
  • 1
    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. – Adrian McCarthy Mar 15 '18 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? – Mosh Feu Mar 17 '18 at 19:42
  • 1
    @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 – VE7JRO Mar 17 '18 at 20:00
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.

  • Ok. I updated my circuit. Can you take a look? Thanks! – Mosh Feu Mar 15 '18 at 17:37
  • Did you also follow the arduino example first? Because if that doesn't work, your segment display is broken. – Michel Keijzers Mar 16 '18 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.