Control Six Non-Addressable LED Strips with One Arduino

YouTuber Trevor Makes shows how to generate 18 PWM outputs with an Arduino Nano to control LED strips.

Jeremy Cook
2 years ago

LEDs, and more specifically LED strips, are one of the top innovations that have enabled makers to create a wide range of fun luminescent objects. These come in two main flavors: non-addressable colored strips, which change colors as a whole based on (generally) three PWM inputs; and addressable LED strips that allow for much more granular control yet are a bit more expensive.

Neither type of strip is likely to break the bank, but if you want to use a three-color non-addressable LED strip with an ATmega328P-based Arduino – a Nano, for example – you’ll need to tie up three out of its six PWM output pins. Want to control two strips? That’s all six occupied, and if you want to drive more than that you’re typically out of luck…

Or maybe you’re not. As seen in the video below by YouTuber Trevor Makes, it’s actually possible to output up to 18 PWM outputs with an Arduino Nano, turning each digital pin (minus the two used for serial control) into virtual PWM pins. The trick to this clever hack is that instead of using the normal Arduino analog write command, Trevor’s code instead uses the interrupts to trigger small bits of code in sequence.

Pin timing is sorted according to duty cycle, and the interrupt service routine, or ISR, actually configures the subsequent interrupt timing as it runs. In this manner, the Arduino is able to generate a virtually unlimited number of software PWM signals. 0 and 100% duty cycle are handled as special cases, as they’re simple binary outputs at that point.

Hardware-wise, Trevor is using a trio of ULN2003 chips to handle the current requirements of two strips each, which elegantly handles his lighting needs. Code and more info on the project is found on GitHub.

Jeremy Cook
Engineer, maker of random contraptions, love learning about tech. Write for various publications, including Hackster!
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles