Happy Holidays!!

After a bit of a scramble late last week, we were able to get v1.0 of the Makerspace sign up at my sons’ middle school Friday morning!

This is the conclusion to the project I mentioned before  (Music and Lights), where an Arduino was used to drive a small speaker and some LEDs.  My initial code was done to play Imperial March (from Star Wars) and Super Mario Bros Overworld Theme.  But the kids would hopefully take it from there and make it their own.

It’s Time to Play the Music…

One of the kids with his dad’s help was able to extend my code to include many more measures of Jingle Bell Rock.   The Arduino code, written in C, was written in a way to make it easy to play any song (single tone at a time).  For example, the first line of the tune:


Looks like this in the code:

// Jingle Bell Rock
int bpm = 120;
int song[100][2] = {

Basically it’s a  2-dimensional array where the entire song is in braces { } where each ‘note’ is a pair of values indicating the note/tone and duration.  Given that it’s single tone music, generally you want to hit only the highest note for each beat to play out the tune.

There are 8.5 octaves of notes available, starting with the lowest at C0 going up through C1, C2, … C7, to the highest at C8.

All 12 pitches of the chromatic scale are represented as follows:

      Cx, Dbx, Dx, Ebx, Ex, Fx, Gbx, Gx, Abx, AAx, Bbx, Bx, …

Where x represents the octave.  NOTE: Lowest note is C0, highest is Eb8.

Note also that the A is represented here by ‘AA’ since A0, A1, etc. are reserved terms in Arduino code-land (represent names of external pins).

A rest is represented by an R (no sound).

Note durations are represented with the following symbols:

  • W = whole note
  • H = half note
  • Q = quarter note
  • E = Eighth note
  • S = Sixteenth

You can represent any other fractions of time simply by writing as an equation in the code, e.g. {C6, Q+E}.

It’s Time to Light the Lights…

Now that we had a tune, we had to decide what our light show would look like.   We had wanted to use Christmas lights controlled by the Arduino.  I decided for simplicity to use an off the shelf relay board (SunFounder 2 channel 5V relay shield) that could be driven by the 5V Digital I/Os.

61bL8+Rf9IL._SL1000_Generally you can use a relay to help you control something high-power or high-voltage like 120V AC electricity with low-voltage, low-power electronics.   Relays have been used in everything from cars to sprinkler systems, having started out from the telegraph.

We decided in the end for simplicity to use 2 sets of lights alternatively blinking for our ‘light show’.  This made my job that much easier.

Hijacking the plugs off an old strand of lights, where one of the wires goes ‘straight through’ connected via a twist-on wire connector and the other wire goes through the relay, here is the setup for controlling 1 set of lights:


Relay set to control one string of lights.

Connecting up the Arduino to the relay involves connecting the 5V outputs previously used to drive LEDs now to drive the input lines on the relay board associated with the light strand we wanted to light.   Due to inverted logic used by the relays, instead of driving a HIGH like we did before with LEDs, the relays now would need to be driven LOW in order to ‘activate’ (connect the lights).

IMG_20141212_073755(Yes, my engineer friends will tell me that if I had connected to the ‘normally closed’ ends of the relay then I probably could have left the drive logic alone, but as a Test Engineer at Freescale who has driven relays in this way for 10+ years, old habits die hard.  Besides for safety reasons just felt that lights should be normally off when the system wasn’t powered).

With the kids we worked out roughly which notes we wanted to light which lights.

IMG_20141212_073731 IMG_20141212_073733

Then the kids made a couple of signs, one of which would house the Christmas lights and our holiday message.

It’s Time to Raise the Curtain…

Will share the code and hookup in a future post (stay tuned for the link).

The cool part is that hopefully with this setup we’ll be able to get the kids a bit more hands-on with the code in the spring!   Wonder what song they’ll think up to do next…


Statler: That was a real wire act.
Waldorf: On this show, everything’s a wire act.
Statler: Why’s that?
Waldorf: Because, you keep asking “Wire they doing it?”

The Revenge of Christmas

Apparently, I didn’t get my fill of building up little Christmas trees— and felt the need to go big!  Actually, a project I took on last week was out of pure necessity.  The inevitable Ghost of Christmas Past that randomly appears in all homes as the boxes come out of attic:  Dead Christmas Lights!!!

Our pre-lit Christmas tree had slowly degraded after cooking through several Texas summers in our attic.   The tree sheds more needles than a real tree and has definitely lost it’s luster.


The Horror

The tree comes apart in 3 sections and has 9 strands of lights (50 each).   I decided I would try to revive the tree with a cool gadget I spotted at Target, the LightKeeper Pro, that advertises itself as “A Cool Yule Tool”.  Hereafter, I will refer to it as my LightSaver Phaser.  Or LSP.


It has several cool features to it, including a light tester, a fuse tester, a light puller, an inductive loop to detect current in a live wire, and a way to ‘zap’ a strand of lights either via an empty light socket or by plugging it directly into the plug on the end of the strand.  Oh, and the handle serves as a storage compartments for extra bulbs and fuses.

As they say, YMMV (Your Mileage May Vary) and mine certainly did.  Of all the features I found the least useful to be the current detector.  Maybe it would work great in a standalone string of lights, but with lights on a large tree, with multiple circuit paths and an aluminum frame, I found that the current detector was very unreliable.   But before we get to that, let’s do a quick overview of what exactly we mean by ‘fixing’ Christmas lights.

What’s in a light?

Per usual when going to fix something I knew some stuff, but some stuff I had to learn.   Of course we all know that mini incandescent Christmas lights are generally connected up in series.  But have you ever wondered why when one light goes out the entire string doesn’t go out?  If they are in series shouldn’t the entire strand go out?

Well, what I learned recently (from a book actually if you can believe that), is that incandescent mini lights, in addition to the filament (what lights up) they also include a “shunt”!  A shunt is an alternate path for the current to go in case of filament failure.    Here for convenience I’ll reference HowStuffWorks:

Shunt in a mini-light

The shunt is of higher resistance than the filament, so when the filament is intact, the current goes through it and lights the light.  When the filament breaks, the current is forced to through the shunt, which is made of a material that will reduce its resistance after a large amount of current goes through it.   So even a “dead” bulb helps to keep his brethren “alive”!

So why the glum tree?

So what is happening in my situation above?  Well, if you have an entire strand of lights that still goes out it could be:

  • The fuse for that strand is burned out!
  • All the lights in that strand are all burned out!
  • One or more lights in the strand has burned out but the shunt is still highly resistive.
  • One or more lights in the strand has come loose out of its socket not allowing current to conduct (or similar where the legs on a bulb just break).

Well let’s just say that on this tree I encountered all scenarios except for the first one.

Basically, fixing lights means either replacing fuses, replacing bulbs, reseating bulbs, and/or forcing shunts to do their job properly.

Oh, Debug Night…

A quick warning:  This sort of debug is very tedious!  But if you’re willing to spend a little time and effort, it can be very rewarding, saving you some $$ that could be spent on other things at Christmas!!

First thing you will need is some spare working lights.  The extras that come with a set of lights are generally not enough to repair a completely broken strand on a prelit Christmas tree.   Fortunately, I had a spare old strand of lights that I use to scavenge working bulbs.


Sacrificial light strand

Check 1:  Fuses

The first thing to check is whether an entire strand of lights appears to be out.  If so, check the fuses that are inside the socket at the end of a strand:


Go ahead and test the fuses in your handy-dandy fuse tester in your LSP.  If any of the lights along that strand are working then it’s definitely not the fuse.  Like I said, for me the fuses were never the source of the problem.

Check 2: Zap the Strand Via the Plug

Next thing you can try with is to use your LSP is to zap the dead strands.  What this does is to send an extra bit of current down the wire to attempt to improve a shunt that isn’t doing its job very well.   First, you can put the plug at the end of a strand into the 2-prong socket on the LSP, shown as 2 horizontal slots below:


LSP plug and light bulb sockets for zapping purposes

Pull the trigger like 20-40 times then check again if any lights recovered.   For me this worked to recover some of the lights!

Check 3: Zap the Strand Via an Empty Light Socket

First of all there SHOULD BE NO empty sockets on your tree!  Empty sockets cannot conduct current no matter what so be sure you don’t have any!

Alternatively, you can take one of the mini-lights out of its socket and connect the empty bulb socket directly to the LSP, this time with the lights still connected to the household wall socket:


Plugging empty socket into LSP

Again, click the trigger like 20-40 times.

TIP:  When pulling lights out on a big Christmas tree it can be really easy to forget where you left that empty socket on the tree which can waste valuable debugging time.  Get an ornament or ribbon to remind yourself where you left those pesky empty sockets!

Again, doing this I was able to recover a few more lights:

IMG_20141201_193154 IMG_20141201_193346

Check 4:  Replace Visibly Bad Bulbs

Before getting to the next step, it’s probably best to attempt to find and replace bulbs that are obviously burned out.   These you can see have black ‘soot’ on the inside of the center of the bulb:


Visibly bad bulb

Replace as many of these bad bulbs as you can!   Test them in the light tester in the LSP after removing them to confirm that they’re dead.

To replace, you’ll need to keep the plastic plug at the base of the bulb and only replace the glass bulb itself as typically the plug and socket have a very tight fit and need to stay together.

From your sacrificial strand, pull what you think looks like a good bulb:


Check the bulb to be sure it’s good before proceeding (no sense in replacing a bad bulb with another bad one!):


Gently bend the metal legs on the outside of the plug downward, and pull the glass bulb out vertically:


Use pliers to straighten the legs:


In doing so, go ahead and scratch up the legs a little with the pliers.  This helps to scratch off any rust that may be on the legs:


Carefully insert the working bulb into the original plug (from the tree this time) so that the legs each go through their own hole:



Bend the legs back up again:


Finally, test out your new light bulb and plug to be sure it works before replacing into the light socket.

Fair warning: I had to do this at least 50 times for the strand at the very top of the tree, that appeared to have been completely shorted out!


Bring out your dead

Check 5: Find the Bad Shunt

Ok, at this point if you still have lights that appear to be out, especially in large groups and there don’t appear to be any “burned out” bulbs, then we probably have a bad shunt or a bad connection in a socket somewhere.

Finding the culprit bulb after attempting all the above will be tricky and require you to be methodical to keep your sanity.

My initial strategy to do this was to use the current detector on the LSP to attempt to find the bad shunt.  The current detector is activated by the large black button on top,  you point the gun at the sockets you want to test, and if they are receiving current you will hear frequent beeping:


Detecting current.

It lights up a red LED but that has nothing to do with whether current is detected.  It’s only there to help you aim the LSP.  The beeping (many beeps in a row) are the indicator.   You’re supposed to go from one light to the next while the device is beeping until the beeping stops.  The socket at which the beeping stopped (or the one before it) is the culprit bulb.

If you suspect a bulb, remove it from its socket, put the LSP on it as before:



If when you put the empty socket onto the LSP, you notice some lights start to come back to life elsewhere on the strand, congratulations!  You found a bad bulb with a bad shunt!

However, if when you pull the bulb out BUT BEFORE you put the LSP on it you notice lights GO OUT, bad news, the light bulb you chose, although not working as a light, still has a working shunt!  It’s not the culprit bulb!

Like I said before, take the ‘current detector’ with a grain of salt.  The instructions say to not touch the tree or wiring while doing current detection.  Also it’s possible that the frame of the tree can interfere with the inductive coupling necessary for the detection to even work.   So you might sometimes just have to guess.

Take heart, young debugger.  You will soon find the culprit bulbs!   Eventually, in one particular area I had to resort to marking all “good” bulbs with a permanent marker on the socket so I didn’t go back and suspect bulbs I had already tested!

After a bit of painstaking work, finally found the 2 remaining culprit bulbs and the Ghosts of Christmas Past (as least for now) were banished!


Let there be light!

I truly wish you well on your debugging quest.  Please comment if you attempt this little adventure!

After Christmas though, I’ll probably be looking for a new tree– one with LEDs!!

LED Advent Wreath

After making an LED Christmas tree, I felt I really had to make an LED Advent Wreath!

I had a circular PCB by chance (as I tend to grab everything I can get my hands on when being recycled!):



I needed something to be the ‘candles’.  Initially was thinking to go with putting the LEDs on the top of real candles to simulate the flame.  But most likely I’d be storing this with the Christmas stuff in the attic after Epiphany and due to the Texas heat we typically don’t store candles there.

So after wandering around the store, thinking that I needed ‘magical colored plastic tubes’, I stumbled on these:



These perfectly fit on some white LEDs I had.  I chose the most purpley and pink ones in the batch and cut them in half.

Next, in order to save myself replacing batteries and to keep the Advent Wreath lit as much as possible, I went and recycled a 5V Power Supply cable I had from an old bluetooth headset.   (Electronics may die but power supplies live forever!).

Hooking up LEDs is generally very simple, you have to choose the proper resistor in series with them to limit the current through them.  Wasn’t sure exactly on mine, but generally white LEDs have a forward voltage of 3.6V and can handle up to 20mA.  I went with 100Ω per on online LED calculator (and because 100Ω is the smallest I have!).


Hookeing everything up to the ring PCB, it looks like this:


5V power supply hookup

Added a way to ‘light’ and ‘blow out’ the candles using some jumpers:


One “candle”. Jumpers added to permit “lighting” the candle.


Almost done!


Lights on!



Straws attached

Found some old plastic wreath material:


Glue gun was already on the table! (Wife making a Christmas wreath):




Now I can keep this Advent Wreath lit much longer than usual!   Happy Advent y’all!

O Tannenbaum…

In the spirit of preparation for Christmas, here’s a neat little Christmas project you can easily do with your kids (or your mom-in-law!):

It’s a $8 soldering kit I picked up a month or two ago at Fry’s, the Velleman “3D Xmas Tree” MK130.  Velleman makes lots of these kind of cool little kits.

My mother-in-law inserting the LEDs to her color arrangement preference.

Some assembly tips:

When inserting the LEDs, be sure not to push the all the way in, leave some extra wire out so you can bend them as shown above.

It’s also very important when inserting the LEDs that the cathode (negative) leg of the LED go into the negative hole of the PCB (circuit board).  Here’s a quick reference:


Do a quick check after all the LEDs are inserted that all of them are oriented properly BEFORE soldering.  If your LEDs dont’ have a flat edge (these don’t) another quick way to double-check is to look inside the “head” of the LED and check that the “bigger” part inside (on the right above) corresponds to the negative side (shown on the PCB with more flat and thicker white).

Same issue with polarity is there for the capacitors.  The caps conveniently have several large “-” signs running down the negative side, which means the other lead needs to go where it says “+” on the PCB.   Be careful also to not insert the capacitors all the way in either, as you need to leave room for bending them down.  Given the “3D” nature of this particular project, having the components not sticking out makes putting together the two PCBs much easier.

Once you have the LEDs where you want them, separate the extra wire on the other side which will serve to hold the LEDs in place while soldering them.  Do the same trick for other components.  I generally wait to clip off the extra wire until I’m absolutely sure that the component is placed properly, as it’s much harder to fix once the leads are shorter!

Finally, be careful when soldering so as to not overheat the PCB causing the pads to lift!  This happened a couple of times to me when making this tree!  Below is an example of lifted pad not from this project, but from a great Adafruit page on common soldering problems (of which I often have many!):


I was able to find which joints were bad by using the circuit diagram enclosed in the box with the kit.  By figuring which lights worked and which didn’t was able to track the problem down to 2 branches of the circuit.


After some tribulation, here is the final result:

Repeat a few more times if desired:


Merry Christmas!