Simple Arduino LCD Clock

A simple Arduino clock is constructed with an off the shelf LCD shield.

 

Introduction

The shield seen below is the LCD Keypad Shield for Arduino. Offering six buttons and an adjustable contrast back-lit LCD screen, the shield is a great extension of the Arduino’s stock hardware. A Modified Ardunio LCD4Bit library & example code can be found on the vendor’s site while the hardware itself can be found on ebay for a greatly reduced price.

arduino-mega.jpg

arduino-mega-with-shield.jpg

Algorithm

The clock sketch (download link below) is a simple bit of c-code (erroneous pun not intended) that offsets a timer by an initial 12 hours 59 minutes. In the code “hbump” and “mbump” are implemented to set the time. These values are incremented and decremented using the directional buttons on the shield. The initial time that was previously mentioned has a value of milliseconds so dividing it by 1000 yields seconds. Dividing again by 60 yields minutes. The break down for hours is just 60*minutes. Finally days is 24*hours or for a 12 hour clock 12*hours. To get the values for the high and low columns in base 10, the quantities are modded by 10 and placed in the lower column. The quantity minus the remainder is placed in the upper column.

clock-example-2.jpg

Finishing Touches

Finally some eye candy is added. Colons between the hours and minutes as well as the minutes and seconds displays alternate on off for an even and odd number of seconds respectively. Meanwhile Unicode 01C2: ? (A Latin Letter For the Alveolar Click (IPA)) scrolls across the top of the display for odd minute values.

clock-example-1.jpg

This character is clearly unsupported by the LCD library but does produce a pretty cool symbol so I kept it. Apparently the mySQL field that holds this post dosen't support it either (thus the ?).

Download the Source

Improved Version

Also be sure to check out the new version Adafruit 7-seg display clock.This version features a real time clock for very accurate time keeping.