Skip to main content
Add Me To Your Mailing List
HomeBlogsRead Blog

Zog's Blog

LED Lighting effects using low-cost Arduinos
By Chris Herzog
Posted on 2/19/2017 9:46 PM

As low cost electronic modules have become cheaper, more prevalent, and easier to use, they are replacing a lot of specialized circuits with more generic and programmable alternatives.

The Arduino (a family of small programmable microcontrollers) is a great basis for all sorts of cool projects. It's easy to drive LEDs, read simple sensors, drive motors, and do networking (wired and wireless).

Here are a few projects for different lighting effects - each includes links to an Arduino project file containing the source code.

    • Railroad Crossing Flasher - flashes two pairs of LEDs (4 outputs total intended to be paired) and uses PWM (Pulse Width Modulation) to give the effect of the LEDs turning on and off by fading on and off like incandescent bulbs
    • Chase lighting (using PWM outputs) - gives a theater marquee chase lighting effect using a configurable number of total LEDs and a configurable number of LEDs active at any given time. It also uses PWM (Pulse Width Modulation) to give the effect of the LEDs turning on and off by fading on and off like incandescent bulbs
    • Chase lighting (using digital outputs) - gives a theater marquee chase lighting effect using a configurable number of total LEDs and a configurable number of LEDs active at any given time. It uses regular digital control for the LEDs (only on and off) but because most of the Arduinos support more outputs for digital control than PWM, it can handle a much larger number of LEDs as part of the chase sequence.
    • Bounce sequence lighting - runs a series of LEDs from one end of the configured outputs back to the other as each end is reached giving a "bouncing" effect between the ends. It supports a configurable number of total LEDs and a configurable number of LEDs active at any given time. It uses regular digital control for the LEDs (only on and off) but because most of the Arduinos support more outputs for digital control than PWM, it can handle a much larger number of LEDs as part of the bounce sequence.
    • Swifty's Toxic Waste - supports a configurable number of LEDs that each "throb" on and off independently with both configurable fade transition and on times for each LED. Used on our layout for a toxic waste disposal industry with a lot of weird leaking, glowing barrels lying around.
  • Swifty's Toxic Waste (Enhanced) - more flexible version which does a few things differently:
    • Configurable values for brighten, maximum, and dimming timing cycles for each LED
    • Configurable minimum brightness value to maintain a baseline LED brightness
    • Uses a logarithmic brightness algorithm (rather than a straight linear approach) for smoother and more attractive LED brighting and dimming cycles. The brightening and dimming cycles are all table driven so that can be changed to whatever is appropriate with effectively an unlimited number of steps
    • Number of LEDS supported limited to only the number of PWM ports on your microcontroller

Wrap up

They should be built using the 1.6.7 (or later) version of the Arduino IDE which can be downloaded free at https://www.arduino.cc/en/Main/Software and were tested using Arduino Uno and Mega 2560 boards. Comments are in the code.

Feel free to download the examples, build them, run them, and if you make some useful modifications you'd like to share, drop me a note at chris.herzog@gmail.com.