Sunday 28 May 2017

Making time for your loved ones

“Talk is cheap. Show me the code.” 
Linus Torvalds

We've been making electronic clocks for a year or so now.  Some recipients and other casual bystanders have asked where they can purchase them. Well, you can't buy them because they are made from scratch!

The first iteration was horrible and looked like a bomb, but slowly we have been able to iron out the bugs and now can put one together in about three to four hours without burning our fingers too much with stray solder.
Call Homeland Security, quick!
It all starts with the following components:
Just add wires!
The ATMEGA328P-PU is the same chip that can be found on the Arduino and in fact with a bit of electrickery the chip can be programmed by the Arduino itself. The chips arrive from the manufacturer for about $1.75 each, but often are missing the bootloader and/or the fuses have been set strangely.  Then, after making the chips receptive to programming, writing the code for the operation of the clock was quite difficult and took many months to get right, containing such gems as:

   if (minset.isPressed()){
      myminute = (myminute + 1) % 60;
      rtc.setTime(myhour, myminute, 0);
      tm1637.printTime(myhour,myminute, true);
      delay(50);     
      mytime = rtc.getTimeStr();
      myhour = mytime.substring(0,2).toInt();
      myminute = mytime.substring(3,5).toInt();
    }

Yup, that'd do ya head in!  Then the wiring commences - and that's damn difficult because of the size of the project and the complexity of the connections.

Looks neat on a diagram!
Looks like the London Underground in real life...
Finally there are two sets of batteries to plug in, one for the RTC and one for the remainder of the components including the microcontroller.  So enjoy the result and don't look for a version in your shop real soon.  If you want to start down this path and just like the idea of building a clock from scratch, we recommend you buy a kit first to get an idea of what a project like this entails...


Of course, some of us hate electronics and just like to curl up with our favourite oversized dog!

The nightly ritual includes a final cuddle before bed





No comments:

Post a Comment