PO Box 6603

Huntsville, AL 35813, USA



LED Effects with Toggle Switches

I’m a firm believer that you can’t have too many LEDs. As I’ve been known to remark on occasion, “Show me a flashing LED, and I’ll show you a man drooling.”

Blog Sponsors

Support My Blog

If you’ve been reading my columns for any length of time, you’ll know that one of my long-term projects is my Inamorata Prognostication Engine (don’t ask). As shown in the image below (and on this YouTube video), this bodacious beauty is festooned with toggle switches, pushbuttons, knobs, and dials (I’m sorry for the poor quality of this image, which I just took with a smartphone).
A portion of the Inamorata Prognostication Engine’s main control panel (Click image to see a larger version — Image source: Max Maxfield)
I’m a firm believer that you can’t have too many LEDs. As I’ve been known to remark on occasion, “Show me a flashing LED, and I’ll show you a man drooling!” In the case of the Prognostication Engine, there are two LEDs associated with each toggle switch and pushbutton. Meanwhile, every knob boasts a ring of 16 LEDs. All of these LEDs are tricolored NeoPixels from those little scamps at Adafruit. At the moment, I’m using the classic rainbow pattern from Adafruit to light up all the pixels and make sure everything is tickety-boo, but now I’m poised to proceed to the next stage. On the bright side, the main control panel with all the switches, pushbuttons, knobs, and dials can be detached from the main cabinet so I can take it home to work on it. On the downside, this is still a somewhat bulky (and definitely fragile) piece of kit, so I want to minimize the number of times I have to transport it anywhere. In order to address this conundrum, last night I created a simple test bench comprising a toggle switch and a 10K linear taper potentiometer. The switch has two tricolored NeoPixels associated with it, while the potentiometer has a 16-pixel ring.
A simple test bench (Click image to see a larger version — Image source: Max Maxfield)
Now I’m poised to start pondering the different types of LED effects we might implement. In this column, we will focus on the toggle switch. The simplest case would be to use two colors to reflect the positioning of the toggle as illustrated in the graphic on the lower-right-hand side of this column. Whichever side the toggle is on (we might think of this as the “active” side), that LED could be yellow, while the other side (the inactive” side) could be red. Note that I’m currently planning on predominantly playing with reds, oranges, and yellows (possibly pinks and purples) because I think these will work best with the wood and brass Steampunk aesthetic of the Prognostication Engine, but I might be tempted to experiment with other colors also. So, the initial effect is that when we flick the switch to the left, the left-hand LED turns yellow and the right-hand LED turns red. When we flick the switch to the right, the right-hand LED turns yellow and the left-hand LED turns red. OK, this isn’t bad, but it’s not exactly earth-shattering. Is there anything we could do to jazz things up a bit? Well, one idea that comes to mind would be to have whichever LED is changing to yellow flash three times (flash-flash-flash-on) before settling into its permanently ON state. Another option when the switch is toggled is to have both LEDs fade from their original colors to their new colors (fade-red-to-yellow and fade-yellow-to-red) over some period of time (say half a second).
Using two colors to reflect the position of the toggle (Click image to see a larger version — Image source: Max Maxfield)
We could also use a combination here, where a transition on the switch causes the newly “active” side to immediately transition from red to a flash-flash-flash-on yellow, while the newly “inactive” side performs a fade-yellow-to-red. Suppose no one touches the switch for some time; say 15 minutes. After that time, maybe we could make the red (“inactive”) LED fade to a low brightness, while the yellow (“active”) LED starts to “breathe”; that is, gradually fade up and down (I’ve also heard this referred to as the LED “snoring” on the basis that we’ve entered some sort of sleep mode). One last point to ponder (for this blog) is what do we do when the system is first powered-up. This isn’t a time to be shy and retiring — we will have to have some sort of power-on effect that effectively says “Tra-La!” using light instead of sound (of course, we will have sound also, but that’s a topic for another day). Of course, since all of the Prognostication Engine’s LEDs are tricolor, we could implement all sorts of additional effects. Over to you — can you think of any other effects I should be experimenting with. I will of course be videoing everything and reporting back in a future column, so now would be a great time to offer suggestions and we’ll see how they turn out.

Blog Sponsors

Support My Blog

0 0 vote
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments

David Ashton

Max… as LEDs are small I’m tempted to say “little things please little minds” but that’s a tad unkind so I won’t….

I have a fibre optic Christmas Tree (no messing round with non-working strings of Christmas lights, I thought – yeah right) It has a module at the base with a bunch of LEDs which feed light into the fibres, which terminate at the ends of all the “branches”. It was fine for a few years and just when I was thinking “Gee, this is the way to do Christmas trees!” the Blue LEDs stopped working (actually I think they are tri-colour LEDS.)

So my mission, should I decide to accept it, is to take the thing apart and find out why the blue driver is not working. I could just buy another tree and send the old one to landfill, but being an environmentally sensitive, bloody minded, stingy, unable-to-admit-defeat electronics techie I will try and fix it, failing which I’ll make my own LED driver for the damn thing.

I think I should have been an accountant, instead……

Elizabeth Simon

I think the color scheme/effects should be affected by the current prognostication state. Perhaps becoming livelier as the overall state improves. Perhaps flash-flash-flash-on for when things are looking good and very slow fade for when things are not looking good.

Another option is to have the lighting effects also depend on the order in which buttons and switched are changed.

I just thought of another effect. Combine flashing with color fade so each flash is a different color….

Blog Sponsors

Buy this space!

Recent Posts

But Where Should the LEDs Go? 

Kan Klive’s Karnaugh Maps Be Korrect? 

Measuring the Width of a Human Hair with a Laser 

Manual Required for Edison Model 35-A Ticker Tape Machine 

Tension Mounts as Sensor Smackdown Looms 

Meet the DrawBo Robotic Drawing Tutor 

I Can Do Anything Better Than You! 

Make Sure “Only” Knows Its Place 

University of Kansas Probes Secrets of Universe 

Not Your Grandmother’s Embedded Systems 


Already a member? Login

Oops, forgot your password?

Please enter your username or email address.
You will receive a link to create a new password via email.

  • Name

  • Usernames cannot be changed.
  • Contact Info

  • About Yourself

  • Share a little biographical information to fill out your profile. This may be shown publicly.
  • Add or Edit GravatarYou can change your profile picture on Gravatar
  • Type your password.
  • Type your password again.

Edit Profile

You must be logged in to edit your profile.

Would love your thoughts, please comment.x