# 2nd LED not working when connected to different GPIO port

I am trying to make 2 LEDs flash but I have connected both to different GPIO ports. Both LEDs are being used with a 220 Ohm resistor.

my red LED is connected to GPIO4 (Pin #7) while its ground is connected to pin #14. This works normally. (I am using LED module from gpiozero by importing it)

However, when I try to run the same set up using a blue LED and connect it to GPIO26 (Pin #37) while its ground is connected to pin #34.

I use the same code on the python, but it does not flash.

• When you try to use the same setup using a blue LED what happens? – user253751 Sep 18 '17 at 23:20
• @immibis it works normally. I also noticed that this happens whenever I use the GPIOzero and not the regular python RPi.GPIO.output(...) objects – tony9099 Sep 19 '17 at 6:25
• So you use a red LED and it works normally, then you use a blue LED and it works normally - then what's the issue? – user253751 Sep 19 '17 at 7:36
• Could you please say this problem also occurs with GPIO19(Pin 35)? – Arun K S Sep 19 '17 at 17:51

LEDs have different characteristics depending on their color. Of significance is the so called forward voltage.

Blue LEDs have a typical forward voltage of 3.3V to 3.4V which is higher than the voltage output of the GPIO pin. So the current through the LED will be minuscule. No current, no light. Red LEDs on the other hand have a forward voltage of less than 2V.

Note that for the same reason the series resistor (in your case the 220 Ohms) need to be recalculated for each color and respective forward voltage. Keep the limits of the GPIO pins (i.e. the max current) in mind though.

A little more detail. This is how the current through the LED depends on the voltage across it. The right side of the I-V diagram is of interest here, forward bias, where the light emission that we expect happens. Increasing the voltage from 0V to near Vd (the listed forward voltage of the LED, look for that value in the data sheet) the current is close to zero. No current, no light. The current however increases with voltages greater than Vd, which will lead to destruction of the LED if the current is not limited, e.g. by means of a series resistor or a current source. Source: https://commons.wikimedia.org/wiki/File:Diode-IV-Curve.svg

There is also a noteworthy detail of the I-V diagram near Vd - the little bend where the current is increases despite the voltage being below the forward voltage threshold. (It also depends how the forward voltage is defined, there are two main methods: 1) the voltage that corresponds to a certain (nominal) operating current or 2) the point where the tangent crosses the x axis.) Either way, it shows that there is a region where a current flows through the LED and thus light is emitted (below nominal brightness though) even if the voltage is below the specified forward voltage.

Assuming the blue LED operates at 3V a decreased series resistor could make it work with the Pi. Using these values

``````Source voltage: 3.3V
diode forward voltage: 3.0V
diode forward current: 16mA
``````

and this LED calculator or Ohm's law we find a value of 22 Ohms. This however might not be the best idea, read below. Reducing the resistor (as stated in the question of 220 Ohm

Caveats:

Using the GPIO pin with a resistor this low, either by mixing something up on the breadboard or if the LED dies in a short-circuit failure mode1, carries the risk of damage the Pi's GPIO pin. So, decreasing the resistor in the current setup might make the LED light up but possibly introduces new trouble, such as overcurrenting the LED (thanks @yo' for the comment) or the Pi, i.e. if the LED shows differing behaviour, not to mention that electrical characteristics are typically temperature dependant.

Footnote:

Electrical leak or short-circuit Electrical leaks, short-circuits and electrical leaks that involve short-circuits are some of the more likely faults that occur in LED devices. Unlike faults in conventional incandescent and fluorescent lights, these faults involve short-circuits and can place a burden on the drive circuit. For this reason, the drive circuit must be designed so that the power supply capacity and the power permitted by the load-limiting resistor allow for situations where a short-circuit occurs. Electrical leaks and short-circuits are caused either by faults or degradation in the semiconducting properties of the LED element, or by electrochemical changes in the materials used.

• thanks. So if I replace the blue led with a red one, it should work eh? – tony9099 Sep 18 '17 at 15:44
• @tony9099 most certainly. – Ghanima Sep 18 '17 at 15:55
• I wouldn't rely on 3.3V - 3.0V = 0.3V that much, there are certain incertainities that could lead to overcurrenting the LED. – yo' Sep 18 '17 at 20:28