Programming Holiday Lights Big and Small

I’ve been spending some time this holiday season writing and setting programs for light displays.  Like many homes around my neighborhood, we’ve installed lights outside to make the house appear festive.  My daughters and I decided to go a little further and picked up a package at the local Home Depot called AppLights for the house this year.  Little did I know this would be the start of a holiday light programming marathon that also included Jewelbots.  More on that in a bit…

We decided to start simple, and get a few strands of lights to line the driveway.  It was a simple install after we extended power from our current display, right next to our giant inflatable dog with a Santa hat.  We staked out the new lights in candy canes and snowflakes shapes then waited for dusk to set the program.

Driveway landing strip

Driveway landing strip

This light-set has a simple set of pre-programmed animations available from a mobile app.  I can connect to the display over bluetooth and choose the animation for each strand to display.  In our case, there are seven strands, and we have them all set to the same animation so that they appear synchronized.  The configuration from my phone is simple enough:

AppLights control application

That’s fun… but I’m a programmer, and want more control than just choosing an animation.

Programming Lights with Jewelbots

I went from programming lights on the house, to programming lights on my wrist.  Jewelbots are described as the friendship bracelet of the future, allowing kids to program an embedded Arduino board.  The board features four LEDs, a vibration motor, a button, a bluetooth radio, and a micro-USB connector. Out of the box, you can use the Jewelbot to detect when other Jewelbot-wearing friends are nearby or to send a series of vibrations to another Jewelbot.  The device is also open for hacking, to allow you to write your own programs and upload them to the Arduino board.

I love the idea of teaching kids about code by interacting with such a cool device that they can easily hack on.  In fact, the entire Jewelbots device is open-source, available on Github, and welcoming for anyone to start writing code.  I was an early supporter in the Kickstarter for Jewelbots and continue to support their open source efforts.

You can download the Arduino editor and toolkit from their website at Arduino.cc  This will give you a simple editor and software development kit that allows you to write applications for your Jewelbot (or any other Arduino device) using C++.  Yes, we can teach our kids to use C++

With the Arduino editor installed, you need to next download the Jewelbots firmware and library from within the Arduino editor.  This is easy to do, from the ‘Boards Manager’ option under the tools menu:

Arduino Boards ManagerKey in “Jewelbots” into the search field, and install both the Jewelbots library and Firmware Update.

Add Jewelbots LibrariesWhen you move your mouse over these items in the window, an “Install” button will appear.  Click it to download and install these components.  Once you have completed that, you can close the Arduino application and re-start it to load the new Jewelbots information for Arduino.

If you’re like me, and you have a Jewelbot handy, plug it into a free USB port and select the appropriate port in the Tools – Port menu:

Select PortNext, we need to update the firmware for the device, so navigate through the Tools – Board menu and select the “Jewelbots Firmware Update”.  To configure the Jewelbot to receive the firmware you need to put it into programming mode by holding the button in the middle for 2 seconds.

Connected Jewelbot

You can then send the firmware to your connected device by clicking the upload toolbar button, the one that looks like an arrow pointing to the right.  You should see some information scroll by in the info area at the bottom of the Arduino application, indicating that the upload was successful.

Program that Jewelbot!

Now that the firmware is updated, we can start writing some C++ with the downloaded Jewelbots Arduino library.  First, be sure to configure the Arduino application to use the Jewelbots board in the Tools – Boards – “JWB” item under “Jewelbots Boards”  Mine reads “JWB nRF51822 (v1.0 32kb)”

Currently, there are some easy to access components made available to us with this SDK including the four LEDs, the button, and the buzzer.  For convenience an Animation class was also made available with some simple animations that we can use with the LEDs. Documentation of the Jewelbots API is available in their Github repository.

I wrote a simple routine to pulse green with the following code:

Its a simple program, but starts down the path of “what else can I do?”

I can upload and have this running on my device by first configuring the Jewelbot for program mode by holding down the button for 2 seconds, and then pressing the upload button in the Arduino UI, that right arrow toolbar button, to upload my code.

Once the code is uploaded, I can unplug the USB from the Jewelbot and see my animation playing:

LED Animation on Jewelbots

LED Animation on a Jewelbot

I’m showing my daughters how to write simple C++ programs like this, a first program that they can see do something on a real device, not just on a computer screen.  I’m really looking forward to the future for Jewelbots.