As part of work research, I was asked to hack a Hasbro toy lightsaber. It was the first time I tried hacking anything at all and I considered it a minor miracle that I succeeded. By hacking, I mean actually replacing the entire electronics, LEDs and the logic chip, and replacing them with my own micro-controller and programmable LEDs while keeping the form and casing intact. I also added an extra button and battery light indicator.
In the spirit of open source sharing, I am blogging about my experience here.
This is the toy model that I used:-
First of all, I de-soldered the original LEDs which were single colour red LEDs and replaced them with two strips of WS2812 LEDs or more commonly known as NeoPixels by Adafruit. The two strips are arranged back to back. Each strip gives out its light in a 120 degree angle, so there is a dark spot of 60 degrees on the left and right but it cannot be helped. Also, the spacing between each LED is quite big since the density is 66 LEDs per metre. Again, this is due to power constraints since I decided to use the original power supply of 3 x 1.5V AA batteries. I could have upgraded the power supply to a Lithium ion battery used by smart phones that have the highest power density among portable power supplies. But I didn’t. Well, maybe this could be a future improvement.
That being said, the replacement NeoPixel LEDs are truely an amazing innovation. You can program them to any colour you want and configure their animation to any pattern you want: blink, fade, ripple effect etc. You can program thousands of these LEDs just using two Arduino pins! The only constraint would be the power supply since each LED would draw 60mA at full white light power.
This is the original logic chip which I did not remove because I needed it as a structural support since the struts fit nicely into the light diffusion translucent plastic sheath of the blade.
So I stuck my own logic chip on the back side of it. I used the SparkFun Pro Micro microcontroller as the brains of my product. I chose it for its small form factor, having to squeeze it into the tiniest of spaces.
The microcontroller runs on 5V. However my battery power output is 4.5V max and this voltage output would deteriorate over time as the batteries drain. So I added in a voltage regulator chip – the Pololu 5V step-up/step-down chip. It is very small and would fit into the crevice in the lightsaber handle. How it works is that you feed it any voltage in a range, say 3-12V and it would regulate it to 5V exactly. The efficiency is pretty good as well. I think it is upward of 70%. This means that the lightsaber power supply would perform consistently until the batteries fall below 3V or something, which would mean the lightsaber would suddenly not light up, and you know you have to change the batteries.
Look at how tiny the Pololu chip is!
As with any electronic prototyping process, you should always test your logic circuit first on a breadboard before soldering all the connections. I tested my programming code for the lightsaber in this configuration before soldering all the connections.
Now I will move on to the buttons. The original button can be seen below. It looks like there are two buttons but they are actually one switch only.
I needed another switch so I can enable toggling between different light animation effects. The original main switch would be to trigger on or off each light animation effect, thereby “freezing” the animation, if say, you only wanted that particular colour without the light animation. This is because each light animation is associated with a different colour. So for example, yellow is for a pulsing effect, blue is for a ripple effect etc. The following describes the various modes which you can see in the video at the end of this post.
1. Red – “Health bar mode”. Pressing the main switch would switch off a few leds at a time starting from the tip of the lightsaber.
2. Orange – “Pulsing mode”. The lightsaber would throb. Fade in and out.
3. Yellow – “Chameleon mode”. The colour would gradually change across the colour spectrum. Click the main switch to freeze at a colour that you like.
4. Green – “Glitch mode”. The lightsaber would randomly show a flicker effect running up or down its length.
5. Blue – “Running lights mode”. The lights appear to be continually running up the lightsaber.
6. Violet – “Sparkly mode”. The lights randomly fade in and out individually.
A few observant ones of you out there may notice that the order of the colours follow the ROYGBIV mnemonic for the order of colours in the visible colour spectrum. I left out Indigo cos it looked too close visually to Blue and Violet.
I made a hole for the additional switch by using my hot soldering iron to burn a hole into the cheap plastic mold of the lightsaber handle. Not very professional I know and even a little hazardous to one’s health. But hey, hacking is about making the best of whatever tools you have to get the job done.
For good measure, I added a green LED to indicate whether the battery power is switched on or not. When I was young, I would sometimes forget to turn off the battery switch for my toys, only to find that the battery has drained the next day. So this LED will be on if the battery power is running to hopefully remind you to turn the switch off if you are not using the toy.
This is what it looks like beneath the hood. The LED is grouped with the Pololu voltage regulator chip.
This pic below shows the step after the breadboard testing when I was trying to plan the layout of the components so that they could fit within the limited space inside. The red SparkFun Pro Micro has to eventually fit inside the plastic sheath which it is sitting on top off now.
And then the soldering begins! A process taking a few hours of delicate surgery-like precision and concentration. The huge magnifier glass desk lamp I used was very helpful. It was all in all, a lengthy and taxing process, both mentally and physically exhausting. Here is the soldered part for the Pro Micro.
The picture below shows the completed circuit with the components fixed in place. The Pro Micro is hidden to the left of the picture, and is followed by, from left to right, the main switch (for switching on and off the animation effect for each animation mode. You can see the back of the switch.), the secondary switch (camouflaged into the black background beneath the mess of wires. Used to switch between animation modes.), the perf board for the wiring connections (the large capacitor is to protect the first NeoPixel in the strips against the power-up surge), and finally, the battery switch.
The final step involves putting the casing back together. I cried out ‘Hallelujah!’ when everything worked.
If I were asked how I could improve this project, I would add a motion sensor and a microphone so that the sword would do a “swoosh” sound when it is swung about. Actually the original lightsaber already had this effect and my hacking is a downgrade in this aspect. Oh well. Win some. Lose some.