Before we dive in into the software, if you want to read about prices, design and hardware use links below. The staircase RGB LED Lighting is attached to the wall and I had a very basic code running for a while. I’m pretty sure that each one of you will adjust the hardware and software to your particular needs, as no staircase is the same!
$20 Automated Staircase RGB LED Lighting: SOFTWARE
While my code was totally workable, I will be sharing the code written by Dean Montgomery it’s far superior to mine and has different effects built in. I’m currently running his (modified) version of the code anyway.
Before we start with the code, we have to trim the PIR HC-SR501 to respond as quickly as possible. The module comes with a jumper setting and two pots to trim the timing and sensitivity. Please read the attached post to set it right.
- Set jumper to repeatable trigger
- Set sensitivity to your desired value
- Set timer to minimum
The sensor outputs a digital (HIGH/LOW) state, and it’s easy to use with Arduino IDE.
I also had to cover up part of the sensor with an electrical tape to decrease the angle of detection. The detection angles will depend on your situation, in my tests I established that I will need a small slit that resembles a predator retina. It’s a 3D printing job queued up for later.
I will walk you through the code so you would know what is what. It will save you some time and allow you to modify the code and effects quickly.
Setting up the variables
The script will wait 3 seconds and flash a rainbow effect to entertain you while the PIR sensors are calibrating and the default (LOW) state is written to the pins.
The main loop
Arduino is pulling the sensors every loop and if any of the sensors return HIGH, an effect is assigned and the LEDs will flash accordingly. Depending on which PIR activates, the array holding the LEDs is reversed to play the animation in the correct direction.
In addition to this, if any of the PIR sensors get activated during the fade out stage, all LEDs will turn bright again to keep the effect up.
Lastly, we have functions that control which effect is applied based on random seed, and what colour palette should be used for the effect.
The effects available:
- rainbow with glitter
There you have it! complete, automated staircase LED lights for less than $20. I have learned from it a lot, especially how to drive the LEDs. In future I will add proper WIFI connectivity to this, so I could also take over the control via web interface. For now I hope you will enjoy the lights you made. I have to say, that guest are very impressed with it, the white trunking blends in nicely, and if not for (yet unpainted) black PIR enclosures, you can’t tell it’s there.
A lot of time and effort goes into researching, prototyping projects and creating articles. All that knowledge has been nicely compressed into a few minutes long article and sometimes a video. If you want to put a monetary value on the time I saved you – Take a look at support me page! I appreciate your support!