0

I want to connect 5 leds (red, blue, green, yellow and white) to my raspberry Pi.

Only 1 led will be lit at a given point in time.

Is it possible to connect them all to a single GPIO port and using 1 resistor?

If this is possible, would they need to be in series or in parallel?

I've seen many examples online but I'm confused. I read about charlieplexing but that seems to overcomplicate things (and for some reason it didn't even have a connection to ground)

3
  • 1
    Not Pi specific.
    – joan
    Jan 23 at 16:33
  • would they need to be in series or in parallel? ... why are those the only options? ... both series and parallel connections would light all the LEDs at the same time
    – jsotola
    Jan 23 at 21:38
  • for some reason it didn't even have a connection to ground ... why would a ground connection be required? ... to light a LED, you need a voltage difference across the LED
    – jsotola
    Jan 23 at 21:40

3 Answers 3

1

Is it possible to connect them all to a single GPIO port and using 1 resistor?

Yes, but without additional hardware, when one is lit, they will all be lit. Which is the same thing as saying, "When the GPIO is ON, it is ON, and when it is OFF, it is OFF."

Charlieplexing is interesting, but strikes me personally as an esoteric solution looking for a problem :) But rest assured that Charlieplexing is incapable of violating the laws of physics, and there will always be a non-zero potential difference between pins before current will flow & an LED is lit. There is no GND identified in the schematics because the voltages at X1 and X2 are reversed to realize the Charlieplexer. AFAIK, this is not possible with RPi GPIO pins, and even if it were, it's still 2 or more GPIOs.

Your objective of Connecting LEDs with least pins and wiring may be more practically reached with an external hardware component similar to the ADG2188 - an 8 channel analog switch matrix with an i2c interface. Or, better still, per @joan's comment, get a PCA9685 - 16-channel LED controller that also has an i2c interface. However, the i2c interface still requires 2 GPIO pins.

1
  • 2
    If you go that route just get a PCA9685 based servo driver board. It is s LED driver after all.
    – joan
    Jan 23 at 20:23
1

No, it s not possible. You need 5 GPIO.

0

They make devices called 1 wire LED WS2812B. Look at this link, it shows how to connect to an Arduino with power, ground, signal: https://www.arrow.com/en/research-and-events/articles/protocol-for-the-ws2812b-programmable-led. There are examples online on how to program this device.

1

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.