I've read that 17 LEDs can be controlled individually with the 17 GPIO pins.
Does that mean that only 5 (17 / 3 = 5.6) RGB LEDs can be controlled with one Pi?

Would it be possible to individually control 20 or more RGB LEDs somehow?

  • 2
    In all the solutions you are likely to get told about you should remember that there is always a trade off between the number of LEDs you want to control and the frequency (how often) you can change the control or setting for each LED! More LEDs = Less often you can change / longer it takes to change the entire settings for ALL of them. 8-)
    – SlySven
    Commented Mar 16, 2017 at 4:57

4 Answers 4


Actually, with 17 GPIOs you can drive 72 LEDs using time multiplex (8 groups of 9 LEDs are driven one after another for such a short time that our eyes believes they are on at the same time, just less bright). Do you can have 24 RGB LEDs this way.

And if that's not enough, you can cascade I2C LED drivers resulting in hundreds of LEDs if you want.

  • OK, lots to read and learn but this sounds like what I need to do. Thanks.
    – barro32
    Commented Mar 16, 2017 at 18:05

Yes and no. If you are talking about discrete LEDs then yes each one will need 3 pins and a common power or ground connection. However, they also make individually addressable RGB LED strips, rings etc. like these Neopixels from adafruit (based on the WS2812), which only require one pin besides power and ground.

  • 2
    From an interfacing point of view, the strips that use TWO pins (Data & Clock, APA102 protocol) as well as power ones are very much easier to interface to the RPi, the ones with only a Data line although cheaper, have much more stringent requirements to create the accurate serial data that needs to be sent down the wires daisy-chained from one LED to the next - this is an issue for the RPi because it is not a micro-controller which can be tasked with a single purpose but a complete "computer" with interrupts and other timing disrupting things.
    – SlySven
    Commented Mar 16, 2017 at 4:53
  • 3
    @SlySven I wouldn't entirely dispute that, although I have successfully used WS2812s with Pis several times via jgarff's rpi_ws281x library. Adafruit have a good writeup on the process here.
    – goobering
    Commented Mar 16, 2017 at 12:13
  • I would also preferentially suggest the use the APA102 LED strings (with data and clock). They can be driven off standard SPI or just bit banged.
    – joan
    Commented Mar 16, 2017 at 12:46
  • @goobering Yeah, I;m watching that library on GitHub myself, but by comparison I cobbled together, in around half an hour from first principles, a bit-banging set-up using Joan's pigpio library that could update my 60 LED APA102 strip at say around 10Hz then I worked out how to use the MOSI/CLK pins (SPI clock and output pins) which is fantastically faster - if I bothered to use the CE pins I might even be able to use those to multiplex multiple strips should the mad impulse to do so ever occur to me...! 8-)
    – SlySven
    Commented Mar 17, 2017 at 16:27

Using LED modules that include the WS2812 controller, you can drive as many as you want from a single pin. You can get them in circles, grids and strips, or individual modules.

See this library https://github.com/jgarff/rpi_ws281x

  • Thanks. I recently learnt about this module, think it's the way to go.
    – barro32
    Commented Nov 7, 2018 at 20:10

using 3 6:64 latches, driven by 6 gpio for the address lines, 2 gpio for the chip select lines and 1 gpio for the desired new state you can control 64 RGB LEDs I.E. using only 9 gpio lines.

By increasing the number of gpio being used for the chip select lines you can easily control even more LEDs. I.E. double the number of LEDs for each additional gpio chip select line. However by routing those first 6 gpio (for chip select) into a 6:64 latch, (and adding another GPIO for this new latch enable) you can control 64*64 (4096) RGB LEDs using only 10 gpio

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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