Knock Clock LED Desk Clock

“Knock Clock” – LED Desk Clock

By: Jake Rice

Overview

This project is a multifunction desk clock designed around the ever-popular Arduino platform that features multiple time display formats, a temperature sensor, indication of the sun’s current position, and a subtle user interface. Currently the gadget is programmed to have three display formats: time in regular Arabic numerals (hh:mm) and in binary (hh mm ss), and temperature in a 2 digit readout with the degrees symbol. However, since it is designed to run off of USB power through a USB to TTL adapter, the display could be programmed to display almost any data that is streamed from the host computer.

Hardware

My project is composed of a number of subsystems that work together to create the final product. These subsystems include a LED array, the DS18S20 temperature sensor, a DS1307 real time clock, a servo based sun position visual representation, and a user input subsystem.

LED Array

The LED array was designed to display numerals that are 4 pixels wide and 7 pixels tall and it can display four of these characters with spaces and room for a colon to separate hours from minutes. This resulted in needing a 147 LED array that was 21 columns across by 7 rows high. I decided to use a daisy-chain of 8 bit shift registers to allow me to control each of the 147 LEDs independently and at full power as opposed to multiplexing the display. Using this approach I was able to control each LED using only three pins on the microcontroller (serial data, clock signal, and latch/strobe signal). To write to the display I pull the latch pins on all the shift registers low, telling them to begin listening for data, then send out the 147 bits controlling the on/off state of each LED in serial. The shift registers are connected in such a way that after the first 8 bits fill up the first register, as subsequent bits are shifted in, the first bit in gets shifted out on the overflow pin and into the second shift register. This allows a single stream of 147 bits to fill up the entire chain of shift registers. Finally, after all data has been sent, the latch pin is pulled high locking the current state of each register until the cycle is repeated.

DS18S20 Temperature Sensor

I interfaced with it using two Arduino libraries that greatly simplified my implementation of the component; OneWire.h and DallasTemperature.h. The current temperature is requested from the chip when input from the user is detected to switch to “temperature mode” in my code.

DS1307 Real Time Clock

I used this component to function as the heart of the clock by accurately keeping time. It interfaces via the I2C protocol and keeps track of hours, minutes, seconds, years, months, days of the month, and days of the week while also accounting for leap years through the year 2100. I have a 3V backup battery connected to the DS1307 to allow the microcontroller to lose power without losing the chip’s time keeping function.

Sun Position Representation

I decided to use a servo motor to represent sunrise/sunset and the sun’s position in the sky throughout the day. A wooden arm with a yellow LED at the end is attached to the servo, which slowly moves it from left to right during the day. Using an online calculator, I found the sunrise and sunset times for Milwaukee for each week of the year and saved this information in two arrays in my code. Once every minute, the program calculates the ratio of the number of minutes elapsed since sunrise to the number of minutes between sunrise and sunset to find where the servo should position the arm. For example, right after sunrise the ratio is near zero placing the arm at its minimum point so the LED is just peeking over the top edge of the enclosure. Since this calculation looks up the actual astronomical sunrise/sunset data, the sun position will remain reasonably accurate during all parts of the year.

User Input

There are only three ways for the user to interact with the device. The first two are simple momentary pushbutton switches on the rear of the clock. These are used to increment the hours and minutes respectively to set the correct time. The third input method involves the use of a piezoelectric buzzer. I used the properties of the piezoelectric material to generate small voltages when the buzzer element is deformed. With the buzzer removed from the plastic housing and glued directly to the inside surface of the top face of the clock, light knuckle knocks on the top face of the clock create small voltages which are detected by an analog input pin on the microcontroller. Using software, the clock listens for knocks and displays the current temperature for 5 seconds if a single knock is detected or it switches between numeral display mode and binary display mode if two knocks are detected within 500 milliseconds of each other.

Software

As a hobbyist I have no formal training in embedded system design, and I am not extremely skilled in writing code. In most cases I probably have not used the most elegant solutions in my code but at the end of the day it works. I am always interested in learning and getting better so I welcome suggestions and optimizations.