I want to control a lot of LEDs (120 LEDs for example) independently of each other using the Raspberry Pi model B+, but the number of GPIO pins in the Raspberry Pi is not enough. So I thought of using the I²C bus since it allows up to 128 devices to be connected to the Raspberry Pi. I followed an online tutorial and enabled the I²C interface on the Pi, but I haven't been able to go further because I have some questions to which I haven't found answers on the internet.

  1. The I²C protocol needs the slaves to have registers of their own and to be able to send ACK bits to the master once a transaction is done. As far as I know, a mere 5mm LED is incapable of this. This makes me think of using some 'middle hardware' that has the necessary intelligence to carry an address (since each slave has an address), and to answer the master back. In other terms, I should't connect the LEDs (and their resistors of course) direcly to the SCL and SDA pins of the pi, I should connect them first to some chip, which is connected to the SCL and SDA pins of the pi. Am I wrong? If so, what am I missing? While searching for a solution, I bumped into datasheet of a PWM LED driver. Can it be of any help?
  2. In case I don't need that middle hardware, how should I connect the LEDs to the I²C bus of the Raspberry Pi (the SCL, the SDA, the ground and the 5V GPIO pins)? There aren't any tutorials out there that clearly explain this issue.
  • Have you considered simply using an Arduino and connecting it to the Pi, lots of tutorials on how to do this on google, and with about 2 arduino Megas you should be able to control 120 leds without a problem Mar 21, 2017 at 16:23
  • 1
    I suggest you look at APA102 LED strips. They have individually addressable RGB LEDs. You can connect thousands of LEDs using such strips.
    – joan
    Mar 21, 2017 at 16:35
  • With the ready availability and ease-of-use of addressable LED strips, it seems like you're making an enormous amount of work for yourself by trying to connect individual LEDs.
    – goobering
    Mar 21, 2017 at 16:59
  • Thanks all for your answers. @MohamedAli, using an arduino leads us to the same problem since an arduino too has a limited number of GPIO pins, am I right?
    – S.E.K.
    Mar 22, 2017 at 11:41
  • @joan led strips are suitable for such a project, but having them attached to a strip is not practical if I want the leds to be mobile.
    – S.E.K.
    Mar 22, 2017 at 11:47

1 Answer 1


You can use I2C controlled PWM LED drivers to control multiple LEDs.

The PCA9685 based modules are a popular choice. Marketed as servo drivers they are in actual fact specialised LED drivers. Each module can control 16 LEDs, and 8 modules may be connected to an I2C bus (many more if you add a multiplexor).

However I2C is comparatively slow and if you want dynamic display updates you are almost certainly better off using APA102 addressable LED strips.

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.