Wall Clock

Brand new project, guys!

So, I decided to make a simple wall clock for my room, based off the Arduino microcontroller.

This post (or this series of posts?) will track my progress with the project.

The active github repository for this project can be found here.

For the software, I use xed to actually write the code, Arduino IDE to upload it to the microcontroller and monitor serial output, and Fritzing to design the circuits (and to occasionally translate any working circuits back to software).

For the hardware, I ran into Chaos-inKL, a local group of technically inclined really good guys, who lent me the components I wanted. Huge thanks, I would otherwise have to spend a small fortune on the components.

With the introductions out of the way, lets begin!

The clock is a fairly simple program and circuit setup right now.

The circuit is simply the recommended connections picked up from the spec sheet of the LCD and the example sketch from the Arduino IDE. Its not a perfect circuit, and is a mess of wires and colors, but as a wise man once said, if it looks stupid and it works, its not stupid.

Coming to the exciting parts of the project, lets talk about the program.

I’d initially forgotten that int is a really small data type, and it tends to overflow rather quickly. My solution to the problem : use long int. Of course, I should’ve used unsigned int, but I’d forgotten that unsigned is a thing, and now, why mess with something which works?

The actual timekeeping is easy, even if inaccurate. The inbuilt function millis() provides the number of milliseconds since system start, and we add an offset number to keep track of what time we started counting time from. A pretty standard conversion from milliseconds to hours+minutes+seconds provides time. For the final display on the LCD, I’ve put in a lot of ugly if-else conditions. The idea is to use the same number of digits on the LCD irrespective of whether the value displayed is single digit or a double digit. I also put in a blinking : separator for time units. I simply display : on even seconds, and display a blank space on odd seconds.

The buzzer functionality hasn’t been integrated into the main program yet. I am still figuring out how to make an alarm ring without messing with displaying the time every second. The timekeeping also needs fixing. While the internal clock does work, it loses a couple of seconds for every hour the Arduino runs. I’ll need something which times more accurately. A quartz oscillator, or an RTC module, I am told, are good choices. I also need to be able to power it from a battery. My initial thoughts went to a 9 V battery. After reading this post, however, I am leaning towards the LTC3525 regulator coupled with a couple (or maybe even a triple) of high capacity AA cells. I also want to eventually figure out a way to display the amount of power left in the battery.

Here’s a couple of photos from its as of now current progress :

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.


%d bloggers like this: