Another Clock to Tick

Posted: December 19, 2011 in Computing, Projects

For the last year or so we’ve been using a toddler alarm clock for Zachary. Since he can’t read time, a standard clock isn’t all that helpful. A toddler alarm clock uses a stop light (red/green) to indicate if you should be sleeping or awake. It’s pretty ingenious and it’s been somewhat successful.

I do have a few complaints though. The selection of clocks is pretty limited, it’s not exactly a market with a lot of options (and they tend to be expensive). I (of course) bought one off Woot when it became available (basically it’s this one). Honestly, it kind of stinks. It’s very hard to set the time (you need to press the button twice to set the alarm, but the buttons are polled from the chip, so you can only successfully double tap 1/4 of the time). It feels like a $1 clock with $3 of plastic.

That said, it’s served us pretty well, but it didn’t fit our needs as well as I might hope. Recently Zee has been waking up at 5:30 or so, climbing out of bed sometime after that, all before the green light. He usually plays quietly, but it’s not a habit that we want to encourage. I thought perhaps we need a state in-between red and green, a yellow state that might say “you don’t have to sleep, but you need to be quiet”. Also because our schedule changes, we have two (and sometimes) three different alarm times that we switch between (which is where the annoyance with setting the alarm time becomes a problem).

Obviously, I wasn’t going to find an off-the-shelf product to do this, so I figured it was time to return to my interest in building Arduino based clocks. Originally I thought I would build an Arduino based clock with three colored LEDs and be done with it. Of course the “UI/UX Designer” in me wouldn’t allow that. After a bit of research I decided that I would pick up a Wise Clock 4 which is basically an Arduino with a better processor, a real time clock module, and a 36×15 Red/Green LED Display (red + green = orange). Probably a bit of overkill (especially because it also includes an Xbee connector and an SD card slot).

I did build the Monochron Clock a while ago, which is cool (and is pretty much an arduino too), but other than a bit of soldering there wasn’t a whole lot of effort involved in getting it up and running. The Wise Clock was about the same effort for construction (maybe even easier), although I did damage the board and had to run an external wire. I also had to finally break down and buy a FTDI Cable to program the board.

I had a little difficulty getting up-and-running since the Wise Clock documentation is a little thin (nonexistent), but I did realize that all the code was written for the previous generation clock, and I had to make two small changes to the code. From there I was off and running.

Of course it’s been years since I’ve written any C code so there was a little bit of relearning things. In the end I did more “poking and praying” than actual programming, especially since there aren’t any true development tools beyond a compiler.

So in the end (after about 10 hours of effort) I completed the code for the clock. It supports up to 9 different saved alarms (so you can easily pull up the one you want to use at bed time). The clock face is inverted with the current mode: Red for sleep, Orange for rise (30 minutes before wake), Green for Wake, and Off (green on black). I could have hard coded everything, but I didn’t want to have to reload code to change alarms or the time, so it has a complete UI for configuration (which I tried to make as easy as possible). You can set the time (which is written to the real time clock module), you can add/delete/edit the 9 alarms, set the brightness of the display, and turn the audio alarm on or off.

The display of the time and alarm was the easy part, building the UI for the rest of the clock took the majority of the time.

So in the end, I spent a lot more money on a clock for my son, it may actually be the most expensive clock in the house. I also spent 10-12 hours by the time it was done. I don’t regret it though. I enjoyed the process and it has reengaged my interest in building more clocks (and writing something other than Javascript and PHP). I might spend a little time refactoring the code of the clock though, it’s not clean, and I really should be leaning more on object oriented programming.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s