Control six separate RGB LED strips with a single Arduino Nano

If you're used to working with individually addressable RGB LEDs, then this title probably scratched your head — controlling six NeoPixel strips is easy with an Arduino, since each strip only needs single pin I/O for data. But we're not talking about individually addressable LEDs; we're talking about conventional common-anode RGB LED strips, and Trevor Makes recently uploaded a video showing how to control six of them with an Arduino Nano.

A common anode RGB LED has four wires: an anode and a cathode for each color. The anode always connects to the positive side of the circuit and connecting each cathode to the negative side of the circuit allows current to flow through that specific LED. A common anode RGB LED strip expands on this concept, with all cathodes chained together per color channel. The operation is the same: connecting a color channel cathode to the negative side of the circuit causes all LEDs to light up in that color.

The Arduino Nano has 20 digital I/O pins available and Trevor needed two for a serial connection. This left 18 pins, which is enough for the three cathodes of each of the six RGB LED strips. If all he wanted to do was set each strip to a single full-brightness color, then that would be simple. But what if he wants something more complex, like adjusting the brightness of each channel to get a more granular color mix?

If all 18 pins were analog, one could adjust the voltage for each color channel of each band to adjust the brightness. But these are digital pins, which can only be turned on (HIGH) or off (LOW). Fortunately, there is a trick: pulse-width modulation (PWM). This modulates the power to a pin and when it happens fast enough it effectively reduces the perceived brightness of the LEDs. But the ATmega328P microcontroller used on the Nano can only output six independent PWM signals, which is not enough to control all 18 cathodes.

Trevor explains how he got around this limitation by implementing timer-based hardware interrupts. This is an unusual and clever use of interrupts and it allows the user to control the individual brightness of each color channel of each LED strip. Trevor discusses the technique in detail in his video, and also has sample code and schematics available on GitHub.

Control six separate RGB LED strips with a single Arduino Nano

If you're used to working with individually addressable RGB LEDs, then this title probably scratched your head — controlling six NeoPixel strips is easy with an Arduino, since each strip only needs single pin I/O for data. But we're not talking about individually addressable LEDs; we're talking about conventional common-anode RGB LED strips, and Trevor Makes recently uploaded a video showing how to control six of them with an Arduino Nano.

A common anode RGB LED has four wires: an anode and a cathode for each color. The anode always connects to the positive side of the circuit and connecting each cathode to the negative side of the circuit allows current to flow through that specific LED. A common anode RGB LED strip expands on this concept, with all cathodes chained together per color channel. The operation is the same: connecting a color channel cathode to the negative side of the circuit causes all LEDs to light up in that color.

The Arduino Nano has 20 digital I/O pins available and Trevor needed two for a serial connection. This left 18 pins, which is enough for the three cathodes of each of the six RGB LED strips. If all he wanted to do was set each strip to a single full-brightness color, then that would be simple. But what if he wants something more complex, like adjusting the brightness of each channel to get a more granular color mix?

If all 18 pins were analog, one could adjust the voltage for each color channel of each band to adjust the brightness. But these are digital pins, which can only be turned on (HIGH) or off (LOW). Fortunately, there is a trick: pulse-width modulation (PWM). This modulates the power to a pin and when it happens fast enough it effectively reduces the perceived brightness of the LEDs. But the ATmega328P microcontroller used on the Nano can only output six independent PWM signals, which is not enough to control all 18 cathodes.

Trevor explains how he got around this limitation by implementing timer-based hardware interrupts. This is an unusual and clever use of interrupts and it allows the user to control the individual brightness of each color channel of each LED strip. Trevor discusses the technique in detail in his video, and also has sample code and schematics available on GitHub.

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow