How to Make Two LEDs Blink with Raspberry Pi

gpioledraspberry pi

I have written a simple Python program which runs on a RPi to make an LED blink. For that I connected my RPi using GPIO 23 with the anode of the LED, and before going back to ground, I added a resistor with 220 ohm. So far, this works.

Now I would like to make two LEDs blink, so I just thought to add a second LED and put them in series. Unfortunately, exactly nothing happened. So I have a number of questions:

  1. Why does nothing happen? Are the 3.3 volts of the RPi too little for two LEDs and a 220 ohm resistor?
  2. Is it even correct to put the LEDs one after the other, or would I need to put them in parallel?
  3. How do I calculate the correct resistor, if I don't know the data of the LEDs? What would happen if I simply remove the resistor? Would I risk damaging the RPi?

Best Answer

To answer your first question, yes. 3.3V is not enough to forward-bias two LEDs, which typically need somewhere around 2V each for red LEDs and more for other colors.

For the second question, putting them in series is entirely reasonable, and often preferred as it prevents current crowding (where one LED with a slightly lower forward voltage "hogs all the current").

As for the third question: You'd have to measure the forward voltage of the LED. Many, if not most, multimeters can measure the forward voltage of a diode, but few (at least that I've seen) can measure voltages as high as most LEDs. Not using a resistor will damage your LED, your rpi, or both, and is not recommended.

To measure the LED forward voltage, try the following circuit:


simulate this circuit – Schematic created using CircuitLab

This will give you an idea of the LED forward voltage. If you hook up this circuit and the LED doesn't visibly turn on (which may happen for high-current blue or white LEDs), try changing to a 100Ω resistor.

A better circuit would involve an active current source, but this one is probably good enough for your purposes.