Hack a Cheap Usb Toy Into a Color-Changing Crystal Clock!
by theaustindixon in Circuits > LEDs
3928 Views, 14 Favorites, 0 Comments
Hack a Cheap Usb Toy Into a Color-Changing Crystal Clock!
I didn't need a webmail notifier though, so I decided to turn it into a really unique clock. I also wanted to improve the aesthetics, so I bought a hollowed out quartz crystal (the kind used to make novelty lamps) on clearance at my local mall for $6. I’ve used these kind of crystals before to make led lamps, so I know how cool they look when they're lit up. You could use something else though, like say an antique lantern, if you can't find a crystal. The sky's the limit really.
I've made two of these clocks now, one for home and on for my desk at work. I used a bandsaw to make a base for one of the clocks out of a piece of purpleheart, but that's not necessary. It looks great just on it's own.
Materials
Building the Clock
Then unscrew the circuit board from the plastic back. The usb cable runs through the back, so you will either have to break the back or cut the wire and re-solder it.
Finally, bend the wire into a friction holder for the circuit board. This will hold the circuit in the crystal. Just run the wire through one of the screw holes in the circuit board and shove it into the crystal. Be careful though, the circuit board is delicate and will break if you're not careful.
Programming the Clock
Great! Saved me a bunch of time. Now my script would just need to reference the driver and determine what command line argument to run. (The programmer was even gracious enough to give me permission to add a link to his driver in this instructable.)
So below is my script (it’s very editable if you wanted to display the minutes or seconds or month ect. instead). Every few seconds the script checks the time on the local system and changes the led’s color depending on the hour; slowly working it’s way up ROYGBIV. So the later in the day it is, the further up on the color spectrum it’s glowing, cycling every 12 hours. I also set it to blink the hour. So if it were 3:00, it would slowly fade in and out once, and then blink rapidly three times.
You will need to download the drivers from the link above, then copy & paste the code below into notepad and save it as "crystalclock.pl". Place the file in the same folder on your computer as the drivers. Then just plug the clock into any usb port on your computer and click on the script to turn on the clock.
#! usr/local/bin/perl
while ($lamprun != 1) # loop keeps clock running
{
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); # finds computer’s time
if ($hour == 1 or $hour == 13)
{
$color=red;
$blink=1;
}
elsif ($hour == 2 or $hour == 14)
{
$color=orangered;
$blink=2;
}
elsif ($hour == 3 or $hour == 15)
{
$color=orange;
$blink=3;
}
elsif ($hour == 4 or $hour == 16)
{
$color=yellow;
$blink=4;
}
elsif ($hour == 5 or $hour == 17)
{
$color=yellowgreen;
$blink=5;
}
elsif ($hour == 6 or $hour == 18)
{
$color=green;
$blink=6;
}
elsif ($hour == 7 or $hour == 19)
{
$color=lightcyan;
$blink=7;
}
elsif ($hour == 8 or $hour == 20)
{
$color=aqua;
$blink=8;
}
elsif ($hour == 9 or $hour == 21)
{
$color=blue;
$blink=9;
}
elsif ($hour == 10 or $hour == 22)
{
$color=indigo;
$blink=10;
}
elsif ($hour == 11 or $hour == 23)
{
$color=purple;
$blink=11;
}
elsif ($hour == 12 or $hour == 24)
{
$color=white;
$blink=12;
}
system(“DreamCheekyLED.exe nopause fade=4000 blink=$blink color=$color”);
}