Export to GitHub

theentropyworks - Clock.wiki


Introduction

I have finally finished my first Arduino project - an alarm clock that knows when I work and when I don't and that adjusts itself automatically for daylight savings time. It has only one button whose sole function is to turn off the alarm. All settings are made over the Arduino's UART.

Why?

I am a letter carrier. I slog snail mail on the streets of San Francisco, California. Until the Post Office discontinues Saturday deliveries I have split, rotating days off. I am off every Sunday and my second day off rotates from week to week so that if I am off on Tuesday this week, I will be off on Wednesday next week. There are also ten Federal holidays every year on which there is no regular mail delivery and I do not work.

The firmware takes all of this into account and has an alarm that only goes off on days that I have to go to work. It also has an alarm that can be set to go of on Sundays, one that goes off on my other day off every week and a one shot alarm that goes off only once after it has been set.

The firmware also takes care of transitions to and from daylight savings time.

Hardware

The hardware is a modified Adafruit Boarduino, on which the 16MHz resonator has been replaced with a 32.768KHz watch crystal and a pair of caps, the fuses modified to use the internal oscillator @ 8MHz and the bootloader replaced with the lilypad version.

Peripheral hardware includes a 2x16 character lcd with backlight, a piezo-electric disk for the alarm, a momentary spst button to turn off the alarm and an npn switching transistor to control the backlight intensity. Date, time, and various alarm functions are set over the Arduino's UART on pins 0 and 1.

Interface

The following table summarizes the strings used to set the clock over the serial interface.

| Commmand | Function | Usage | Description of arguments | |:-------------|:-------------|:----------|:-----------------------------| |d |set date |dmmddyyyy| | |t |set time |thhmmss| | |o |set day off |od |d is an integer from 0 to 5. use 0 if this is your 6 day week, 1-4 for monday through thursday or 5 if you have the weekend off.| |aw |work day alarm|awhhmm| | |as |sunday alarm |ashhmm| | |ad |day off alarm |adhhmm| | |ao |oneshot alarm |aohhmm| | |sw |enable work day alarm|sw | | |ss |enable sunday alarm|ss | | |sd |enable day off alarm|sd | | |so |enable oneshot alarm|so | | |cw |disable work day alarm|cw | | |cs |disable sunday alarm|cs | | |cd |disable day off alarm|cd | | |co |disable oneshot alarm|co | | |x |turn off alarm|x | | |b+ |increase backlight|b+ | | |b- |decrease backlight|b- | | |B |set dst start |Bodmm|where mm is the month, d is the day of the week and o is the ordinal of the day. 1-4 indicate first through fourth and 5 indicates last. B2003 sets the dst start to the second sunday in march.| |E |set dst end |Eodmm|E5010 sets dst end to the last sunday in october.| |T |test alarm |T | | |D01 |dump date & time|D01 | | |D02 |dump day off |D02 | | |D04 |dump alarms |D04 | | |D08 |dump calendar |D08 | | |D16 |dump next observance|D16 | |

More to come