1

The model name is 5161BS

enter image description here

Pins 3/8 are input and the rest are output for each individual segment.

I have connected pin 3 to the 5v pin on the Arduino, and the rest to individual digital pins.

With a simple sketch with the pins set to mode output, all segments are lit.

My concern is that the way I am turning off each segment is by setting the output pin to high.

Meaning

5v pin --> LED <-- Digital pin

Is this dangerous to have two voltage sources going in the same direction? Is there another way to do this?

| improve this question | | | | |
  • 1
    Do you have current-limiting resistors? This is the first question. Otherwise you are probably damaging something. – Nick Gammon Mar 10 '16 at 23:14
  • Fortunately I put a 330 ohm resistor from the 5v pin. But no other resistors. – chris.fy Mar 11 '16 at 0:23
  • Well that is better than nothing. However when multiple segments are displayed they will have different brightnesses because that one resistor will have different currents through it. You really need 330 ohm on all the pins except the 5V one. – Nick Gammon Mar 11 '16 at 1:10
  • @NickGammon I'm not sure about that. I'd expect any segments that are lit to have the same brightness, though the brightness of each LED will increase as fewer LEDs are lit, since theres more current to go around. – SoreDakeNoKoto Mar 11 '16 at 15:24
  • @TisteAndii, they would have the same brightness if they are identical. But only a slight difference in the voltage drop leads to a large bias for current flow when hooked up this way. – BowlOfRed Mar 11 '16 at 19:05
1

This is called a common-anode LED. The anodes (+ side) are shared. They probably dedicate two pins (3 and 8) to share the current to the anodes.

Connecting the common anode to +5V is fine. However you should have current-limiting resistors between each of the other pins (the cathodes) and the Arduino digital pin. Otherwise you are getting the Arduino to try to "sink" its own 5V supply through a digital pin, which far exceeds its rating. You will probably damage the output driver MOSFETs and they will stop working. Plus the excessive current will damage the LEDs as well.

See the LED resistor calculator. Something like a 330 ohm resistor, in series with each of the cathodes, should be adequate.

Now, setting the digital pins to output will "sink" 10 mA or thereabouts from +5V, through the LED (which lights up) and through the digital pin to ground.

You control what "number" you see on the LED by turning off the appropriate pins, to make the segments light up.

Also see The care and feeding of LEDs.

| improve this answer | | | | |
2

The device you have is a common anode display. This means that the anodes (+ve terminals) of all the LEDs are connected to one common pin (well, 2 pins actually, pin 3 and 8 are connected internally) . Their cathodes (-ve terminals) are what make up the remaining pins. Now, to light up any LED, you need 5 V at its anode and GND at its cathode. You have connected 5 V to pin 3, which stands for the common anode of every LED, so all that is left for any LED to turn on, is for you to connect GND to its corresponding cathode. So when you made all the remaining pins (the cathodes) OUTPUT, by default the Nano sets those pins to a logic LOW (or GND) value, so ALL the LEDs got lit up. Each LED now has 5 - 0 = 5 V across its terminals and is forward-biased.

However, when you write HIGH to any cathode, the potential difference across the associated LED/segment is now zero, because that LED has 5 V at its anode (pin 3/8) and 5 V at its cathode (as a result of writing HIGH), and 5 - 5 = 0 V so it is reverse-biased (at least 2 V or thereabouts is needed for a red LED to become forward-biased) and so the segment turns off. And this is how you control which segment is on at any time: You write a LOW to a cathode to turn on the associated segment, and write HIGH to turn it off. It sounds counter-intuitive but it follows if you think about it. Regarding your question, there's no damage being done to anything; the minimum voltage across the LED is 0 V (well below its maximum peak inverse voltage), while the maximum voltage across the LED is around 2 V, if you use the highly recommended current-limiting resistors (220/330 ohms is good) in series between each cathode and its Arduino digital pin.

Without any resistors, you will be drawing a lot of current through each pin, in total, a lot more than the Nano can safely supply. Use resistors that limit the current through each LED to 10-20mA.

| improve this answer | | | | |

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.