Hallway Lighting Project: Controller & PSU

If you replicate this hallway lighting project, you will be the envy of your family, friends, and neighbors.

In my previous column, I explained how -- as part of a hallway redecoration project -- I decided to embed NeoPixel strips from Adafruit in the skirting boards.

The next step was to create a control system and power supply unit (PSU). For this project, I decided to use an Arduino microcontroller development platform as the controller, because this was the microcontroller I'd already been using with my earlier NeoPixel experiments.

Mounting the controller and power supply
The Arduino and associated shield sit inside a double-gang dry liner box. The controls and LCD display are mounted on a double-gang blanking plate.

Four spare linear 10KΩ potentiometers I had kicking around to control pixel brightness, speed of effect (where applicable), and any other effects appropriate to the currently-active lighting mode

The rotary encoder has a built-in push button, which is used to put the system into and out of standby. Standby shuts of the power to the NeoPixels by way of a Beefcake Relay Control Kit from SparkFun. The relay is capable of switching 10 amps, but I wasn't happy with the contact bounce because I felt it would ultimately harm the NeoPixels, so I sourced a solid state version from Farnell Electronics (a.k.a. Element14) and swapped out the relay. Now, when powering-up, I see far less noise and the pixels don't seem to flash like they did with the original relay.

The contact bounce on the rotary encoder was quite bad, and using capacitors and pull-up resistors across the two outputs wasn't enough to clean up the signals. I had read an article a few months back in Everyday Practical Electronics magazine regarding rotary encoders and the use of de-bounce chips, so I decided to employ one. The article recommended the MC14490P. These were in short supply, with long lead times in the UK, so I ended up ordering them from Futurlec in the USA. As it turned out, they were actually shipped from China and I got slammed for import tax at about three times the original cost of the chips. I challenged UPS about this and they subsequently dropped the charge. I also used the chip to de-bounce the push button. In hindsight, I would look to use a better filter on the encoder outputs and do away with the chip.

I used both of the Arduino interrupts -- one for the standby button and the other to detect rotary encoder movement. (I ANDed the two rotary encoder outputs and fed the output from the AND gate to the second interrupt.)

The LCD display uses six digital I/O (input.putput) pins, plus an additional pit to control the backlight. Another digital I/O pin is used for the encoder LED. The encoder LED is common anode, and the anode pin is also common to the push-button. This means I have to use a pull-down resistor for the push button's open contact. The four potentiometers are wired to four of the analog inputs, with 0V and 5V connected to either side of the potentiometers' wipers. The power is supplied to the Arduino through stripped-back USB cable. I was tempted to power it through the 5V pin, but I read somewhere that it's possible to damage the Arduino that way. I have yet to draw a schematic of the circuitry, but hopefully my description above paints a reasonable picture.

At the outset this eeems like a simple thing to do, but take care. Changes in approach often may mean rewriting your driver from scratch. After working with a customer who chagend their mind frequently I created an approach to allow a systematic method to create hierarchical menus and how to display dynamic data within that.

I wrote it up in a Circuit Cellar article "hierarchical menus in embedded systems" published in issue #160, November 2003. Circuit Cellar's business model requires you to pay a small amount, and for articles of that age you have to download the whole magazine. Let just say that the code was written for the Rabbit micro, but is all in C and should be easily portable.

Jack focuses on software, but there are other techniques. A pullup resistor with a capacitor works well (preferably followed by a schmitt trigger) for slow responses although you should be aware that when you close the switch a short spike of high current will flow through the switch. You can limit that with a small series resistor. A cross coupled NAND or NOR gate combination will work if you have a changeover switch. Also if you use a non-inverting buffer (like 2 x 74HC04 in series or a MC14050) and connect the output to the input by a 10K resistor and also use a changeover switch you will have a debounced output.

Other manufacturers also make debounce chips. Maxom does the MAX812 and several others. See this app note.

Hi Steve -- this looks like an amazing project -- I hope one day to see it with my own eyes -- with regard to the links to interesting sites and videos, I have to say that I love the christmas tree one -- wow!