Build Your Own Gesture Switch for LIFX Bulbs
Wi-Fi-Enabled LED Light Bulbs Controlled Using a SmartphoneBy Emran Mahbub
Co-founder of Hover Labs
Assembly Time: 3 hours
Skill Level: Intermediate
I'm a big fan of LIFX bulbs. These are Wi-Fi-enabled LED light bulbs that can be controlled using a smartphone. I love how these bulbs have the ability to change color and give me the convenience to set the mood lighting from the palm of my hand. But, what if you don't like the idea of having to always use a phone to control the lights?
The solution is simple – a dedicated connected switch anyone can use. But, to make this lighting setup as tech savvy and modern as possible, what you need is a touchless gesture switch that you can control by waving your hand.
Required Parts and Tools:
Spark Core Microcontroller
Hover Hand Gesture and Touch Sensor Development Kit
7 Jumper Wires
USB Portable Charger or 3.6V LiPo Battery
Step 1: Getting StartedThe first thing you'll need to do is get your Hover and Spark Core setup correctly. Use this hookup guide and verify that you can see the gestures being printed to the serial monitor.
Next, setup Spark's command line interface so the PC can act as a bridge between the Spark Core and the LIFX bulb. You can use this tutorial to help you get Spark running on your PC and then use this guide to install the DFU-Driver on Windows.
Once you remove the PC to Spark USB connection, your setup should look like the one below.
Step 2: Spark Core SoftwareHere's how the gesture switch works:
1. The Spark Core will detect a gesture on the Hover
2. Spark Core sends the event to a node.js server running on the PC
3. The node.js server sends a command to the LIFX bulb
For that reason, the most important and most involved part of this project is the software. All the code for this project is available on this GitHub page.
Browse the /examples directory of the Spark Core and then flash it with the code in the /spark folder. You'll need to make two small changes to the code. Add a sendEvent() function to publish the gesture event to the node.js server and add a call to that function after the line that prints to the serial monitor.
That's all the code running you need to do for the Spark Core. Next is the node.js server.
Step 3: Node.js ServerDownload these sparknode and LIFX packages for node.js. To install them, browse to each directory and run 'npm install'. From the GitHub code in Step 2, browse to the /node folder and copy the cli.js file to the LIFX package folder.
Next, open the node command prompt and run 'spark login' to get your access token and then 'spark list' to get your key. Write these down and paste them into the cli.js file on line 6.
Turn on your LIFX bulb and browse to the LIFX package folder and run 'node cli.js'. You should see a message that reads "Spark Core and LIFX bulb was found."
Step 4: TestingNow for the fun part. Wave your hand up and down to turn the LIFX bulb on and off. Next, wave your hand left or right to cycle through the colors. Three colors should appear as you wave your hand: red, purple and white. By modifying the light color[ ] array contents you can easily add more color and brightness level settings.
Step 5: Adding an EnclosureOnce you have the software and hardware working correctly, you can transition your breadboard to an enclosed switch.
I used old phone packaging for the enclosure and painter's tape to keep everything in place. I spray painted the outside black, as seen in the video above.
Step 6: Enjoy!Now by a simple wave of the hand, anyone can turn the LIFX bulb on, off or cycle through different colors – all without using a smartphone!
See other Hover Lab projects.
Emran Mahbub lives in the San Francisco Bay Area and is a co-founder of Hover Labs. Emran has been a Jameco customer since 2013. You can find him on Twitter @emran_mahbub.