Simulating the Slight On/Off Fade of Incandescent Lights When Using LEDs

When LEDs turn on, they reach their full brightness more quickly than incandescent lights do, and when they turn off, they reach full darkness more quickly than incandescent lights. The effect is particularly noticeable when comparing flashing LEDs with flashing incandescent lights, such as the red lights on railroad crossing signals. The difference is slight, but it’s perceptible enough that they don’t look quite right on layouts depicting a time before LEDs were used in crossing signals. To look right, there should be a barely perceptible moment in time when you can see some amount of light in both lights at the same time. I’ve wanted to find a way to simulate that effect by making the LEDs in my signals fade on and off at a similar speed, instead of having them just alternate between on and off. Having recently discovered Arduinos, I’m excited that I can achieve this look on my future crossing signals (and other types of lights) by using an Arduino to control them.

I wrote code that creates a timer for alternating between two phases, and initiates fade-on and fade-off functions for both lights each time the phase changes, at a suitable rate for grade crossing signals (45 to 65 times per minute, according to the Federal Highway Administration’s Railroad-Highway Grade Crossing Handbook). The effect is definitely an improvement over non-fading LEDs, but I still have some tweaking to do to make it just right. They look better, but still not quite right. Viewing the alternating LEDs in a slow-motion video recorded on my iPhone reveals that there is just a little bit too much overlap, when compared to a slowed-down video of an actual railroad crossing signal. I think I read once that the method I’m using to alter the brightness of LEDs (255 steps using pulse width modulation) doesn’t scale linearly with duty cycle. The brightness is slow to ramp up, then increases exponentially with duty cycle. I should be able to write different code to accommodate this.