Management six separate RGB LED strips with a single Arduino Nano
October twenty seventh, 2022
—In the event you’re used to working with individually addressable RGB LEDs, then that title in all probability has you scratching your head — controlling six NeoPixel strips is straightforward with an Arduino, since every strip solely wants a single I/O pin for information. However we aren’t speaking about individually addressable LEDs; we’re speaking about standard common-anode RGB LED strips and Trevor Makes not too long ago uploaded a video demonstrating find out how to management six of them with one Arduino Nano.
A standard-anode RGB LED has 4 leads: one anode, and one cathode for every colour. The anode all the time connects to the optimistic aspect of the circuit and connecting every cathode to the unfavourable aspect of the circuit permits present to stream by that particular LED. A standard-anode RGB LED strip expands on this idea, with all the cathodes chained collectively by colour channel. The operation is similar: connecting a colour channel cathode to the unfavourable aspect of the circuit causes all the LEDs to gentle up in that colour.
The Arduino Nano has 20 obtainable digital I/O pins and Trevor wanted two of them for a serial connection. That left 18 pins, which is sufficient for the three cathodes for every of the six RGB LED strips. If all he wished to do was set every strip to a single full-brightness colour, then this may be easy. However what if he needs one thing extra complicated, corresponding to brightness adjustment of every channel to realize extra granular colour mixing?
If the 18 pins had been all analog, one may alter the voltage for every colour channel of every strip to regulate the brightness. However these are digital pins, which may solely be on (HIGH) or off (LOW). Luckily, there’s a cheat: pulse-width modulation (PWM). This modulates energy to a pin and when that occurs quick sufficient, it successfully lowers the perceived brightness of LEDs. However the ATmega328P microcontroller used on the Nano can solely produce six impartial PWM alerts — not sufficient to manage all 18 cathodes.
Trevor explains how he obtained round that limitation by implementing timer-based {hardware} interrupts. That is an uncommon and intelligent use of interrupts and it lets the consumer management the person brightness of each colour channel of each LED strip. Trevor discusses the method intimately in his video, and likewise has instance code and schematics obtainable on GitHub.
You’ll be able to observe any responses to this entry by the RSS 2.0 feed.
You’ll be able to depart a response, or trackback from your personal website.