Skip to content

The AVR Alarm Clock is Complete

September 23, 2012

After a long pause, I finally took the time to complete my AVR-based alarm clock project this weekend. I redesigned many parts of it in order to simplify the design, maximize robustness and minimize the amount of work required. As such, I decided to use off-the-shelf components where possible. I had a billion ideas for cool features to add to this alarm clock, but since I have a tendency to get carried away, I decided to keep the plan simple: my initial goal is to complete a basic, usable alarm clock. No more, no less.

The completed clock incorporates the following modules and parts:

  • ATMega64 microcontroller board running at 8 MHz ($15)
  • HD44780-compatible 20×4 blue LCD screen ($7)
  • 4×4 matrix keypad originally intended for DTMF ($2)
  • DS1307 real-time clock I2C module with battery backup ($3)
  • Passive buzzer and red alarm status LED ($2)
  • Custom output module with ULN2803 darlington array ($2)
  • Custom interface modules for the keypad and LCD ($3)
  • Custom built 5V switching power supply module ($4)
  • Custom 10 pin in-system programmer extension/jack ($3)
  • Black 8x4x2″ project box ($5)
  • Velcro strips to hold the modules to the inside of the project box ($4)
  • Dupont jumper cables to connect the various modules together ($2)

The modules are connected together using simple pin headers and dupont jumper cables. These cables are inexpensive and come pre-assembled, saving me the time and effort of crimping my own connectors. The ATMega64 board is very much overkill for this project, but the board in question is only a few dollars than weaker alternatives and has many I/O pins, leaving room for future expansion.

The source code for the alarm clock is written entirely in C and compiled with avr-gcc. I used an I2C master library written by Peter Fleury to interface with the clock module, but wrote custom drivers for the LCD and DS1307 chip, which fortunately wasn’t very difficult. I used an usbasp programmer with the avrdude software to flash the microcontroller. The tools worked perfectly on my Linux machines and I would recommend these to anyone who wants a cheaper (or more portable) alternative to the Arduino.

The clock, as it is now, is very basic. It does, however, have a several advantages over commonly available alarm clocks, such as:

  • Keeping track of the date and weekday.
  • 24-hour time, avoiding AM/PM confusion
  • Silencing the alarm does not turn the alarm off, it will ring again the next day
  • The time and alarm can be set with the numerical keys, minimizing keypresses
  • A distinctive red LED indicating when the alarm is on
  • A battery backup: power outages will not cause the time to be lost

There are of course many possibilities for future improvement, such as supporting different alarm times on different days of the week and automatically taking holidays into account. I installed an in-system-programming port on the back of the alarm clock so that I can upgrade its firmware without needing a screwdriver. I can even reprogram it while it’s running.

If you’d like to take a peek, the source code for the AVR alarm clock is available on github.

  1. badnmad permalink

    // If any key is pressed, or one hour has elapsed
    if (keys != 0 || cfg.alarmTime.hour != curTime.hour)

    Are you sure this is OK? If alarm starts at 7:55:00 then (cfg.alarmTime.hour != curTime.hour) will be true after only 5 minutes.

Trackbacks & Pingbacks

  1. Some Glues don’t mix with Electronics « Pointers Gone Wild
  2. Dynamically Adjusting LCD Brightness with Ambient Light « Pointers Gone Wild

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 )

Connecting to %s

%d bloggers like this: