This is a bit home automation but if I want to control my 12v LEDs and I have 8 free pins would it be possible to drive 16 lights as a matrix. I was looking into running 8 LEDs with an 8 channel relay but the I got to thinking if I wire up 16 LEDs in a matrix I could still control them all with those 8 channels. Problem is I was looking at mechanical relays that would burn out very quickly with that kind of switching. Are there any other solutions?

  • Why mechanical relays? since they are 12V leds you will need 12 MOS (4 nMOS on the columns, 4 pMOS on the rows and 4 more nMOS to pull the pMOS gate to ground (since your arduino can output at most 5V). they are much cheaper than relays, much smaller, much faster and will last much longer...
    – frarugi87
    Feb 10, 2016 at 16:50
  • I originally found the relays that we rated for ac and DC and it seemed nice to have the option.I started looking into solid state relays but couldn't find a balance between price, quality, and available datasheets. I'm way more of a software guy so that explains why transistors slipped my mind
    – Jacob Kern
    Feb 10, 2016 at 17:01
  • If you want AC support then you'll definitely need to wire them one by one, or you'll maybe get some weird behavior. As for relays, you will not be able to use them in a matrix. The reason, apart from the wearing, is that a common relay needs 10-20ms to switch, and you will need at least 200 flashes per second (but more is much better) to get an acceptable light. I mean, if you turn on an led for 10ms and then off for 30ms (100Hz switching frequency) your light will blink at 25Hz, and your eye will see the light "flashing", which is really tiring for the eyes. So.. Just go with transistors ;)
    – frarugi87
    Feb 10, 2016 at 17:06
  • 1
    @frarugi87 Yes, thanks again, I decided 120vac would be many more problems than it's worth and I have a main priority of not burning the house down :)
    – Jacob Kern
    Feb 10, 2016 at 17:23
  • @JacobKern How's your project going? Did the answer lead to a solution?
    – Paul
    May 11, 2016 at 14:11

2 Answers 2


You can use ULN2803 driver IC on sink side (cathode), P channel MOSFET on anode/source side of common anode LED matrix. Since you need only 4 sinks you can pair every 2 i/o of ULN2803 so you can drive/sink 1A max load per row. This IC is cheap and widely available.

MOSFET current and speed should match those of ULN2803. You can use BJT instead of MOSFET, but voltage drop on BJT will be higher.

Similar design is here: 8x8 LED matrix

  • The real gem is your similar design. It shows two daisy-chained shift registers. So with the 4 pins, you can drive the two shift registers, who drive the P-channel and ULN2803. Effectively 8x8 with only 4 inputs and it's even very scaleable.
    – Paul
    Apr 11, 2016 at 12:56

I think the best solution would be to use WS2812 LEDS. I already implemented this many times also for my home illumination. WS2812 is a RGB LED with an integrated chip (1m strip with 60 LED will cost about 10$). One advantage is that you need only 1 output from your Arduino and the library works very well. Another one is that you don't need power! 5mA is enough to drive 1000 LEDS! So you don't need MOSFETS and you don't need any Relais.

  • I would choose an SPI based digital ledstrip. They're easier to control with various devices and leave soms time inbetween setting pixels to be able to calculatie the next one. Which is much more memory efficiënt.
    – Paul
    Jan 6, 2017 at 20:54

Your Answer

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

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