Management Six Non-Addressable LED Strips with One Arduino

0
7
Adv1



Adv2

LEDs, and extra particularly LED strips, are one of many high improvements which have enabled makers to create a variety of enjoyable luminescent objects. These are available in two foremost flavors: non-addressable coloured strips, which change colours as a complete based mostly on (usually) three PWM inputs; and addressable LED strips that permit for way more granular management but are a bit costlier.

Neither sort of strip is prone to break the financial institution, however if you wish to use a three-color non-addressable LED strip with an ATmega328P-based Arduino – a Nano, for instance – you’ll have to tie up three out of its six PWM output pins. Need to management two strips? That’s all six occupied, and if you wish to drive greater than that you just’re sometimes out of luck…

Or possibly you’re not. As seen within the video beneath by YouTuber Trevor Makes, it’s truly potential to output as much as 18 PWM outputs with an Arduino Nano, turning every digital pin (minus the 2 used for serial management) into digital PWM pins. The trick to this intelligent hack is that as a substitute of utilizing the traditional Arduino analog write command, Trevor’s code as a substitute makes use of the interrupts to set off small bits of code in sequence.

Pin timing is sorted in keeping with obligation cycle, and the interrupt service routine, or ISR, truly configures the next interrupt timing because it runs. On this method, the Arduino is ready to generate a nearly limitless variety of software program PWM alerts. 0 and 100% obligation cycle are dealt with as particular instances, as they’re easy binary outputs at that time.

{Hardware}-wise, Trevor is utilizing a trio of ULN2003 chips to deal with the present necessities of two strips every, which elegantly handles his lighting wants. Code and extra information on the undertaking is discovered on GitHub.

Adv3