I'm currently working on a "rotating cube" project where a raspberry pi will be used to determine which cube face is at the top and any given time using an accelerometer and light it up with LEDs.

So, I have the bare bones working and the code pretty much there, I can have the pi light up one of six LEDs depending which way up the accelerometer is. The next step would be to have 9 LEDs light up for each face, however I know that the GPIOs have a current limit that should not be exceeded (~50 mA).

So I need on some advice on how to go about this as I am abit of a noob when it comes to electronics. What I was thinking to do was to use a relay board to supply each set of 9 LEDs with more power, something like this;

8-Channel-SSR (ebay)

So my understanding is ill be able to control the relays from the pi, but use an external power supply (5 V) to power the LED sets when switched?

Is this the right way of going about this? Is there a better way?

FYI these are the LEDS that i am using;


2 Answers 2


You could use one or more ULN2003A which are just like a relay but much cheaper.

E.g. http://www.hobbytronics.co.uk/uln2003a-darlington-array?keyword=uln2003, each one will drive seven LEDs.

Using the ULN2003A (or similar) you'd need one gpio per LED.

Alternatively you could use one or more MCP23017 port expanders.

E.g. http://www.hobbytronics.co.uk/mcp23017-16bit-port-expander?keyword=mcp23017, each one can drive 16 LEDs per chip.

The MCP23017 connects to the I2C bus and you could have up to 8 on the I2C bus. The I2C bus is just two gpios, so with two gpios you could control up to 128 LEDs.

  • Hey, thanks for the reply. Could you help me understand the ULN2003A a bit better as I think it may be just what I need if I can connect several LEDs to each output. Where do I connect the external power source that will actually power the LEDs? Thanks
    – Pys3nberg
    Feb 15, 2015 at 22:42
  • Have a look at ULN2003A for the LED connections (you don't have to use 12V). The left hand side of the diagram is not what you want. E is connected to Earth but 1B to 7B would be connected to Pi gpios. Switch a B pin to switch the corresponding C LED.
    – joan
    Feb 15, 2015 at 22:51
  • Ahhh I see, so what ill actually be doing by turning on one of the gpio (B pin) is completing the circuit between the 5V on the right hand side to the (com)? And thus lighting the led(s) connected to the corresponding (C pin)?
    – Pys3nberg
    Feb 15, 2015 at 23:04
  • Yes, that's correct. You switch on the route to ground for the LED circuit.
    – joan
    Feb 15, 2015 at 23:07

This baby controls up to 24 LEDs. I'm using a similar one for PWM output for a quadcopter I am coding. Perfect for your needs! 24 Channel LED Driver The code to control it is fairly simple as well. Message me if you want some advice on this little dude.

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.