Alarm clock from Atmega328 and 7-segment display

This might seem trivial compared to some of the fancy things I have seen here (I'm still learning!) but it was fun.

I got a spare Atmega328 chip, a spare 4-digit 7-segment display, a spare prototyping board, and a few miscellaneous parts, to make a fairly sophisticated alarm clock:

Full details, including the circuit and sketch are here:

Basically it sounds an alarm at a designated time, every weekday (but not weekends), automatically dims at night, and can be converted to daylight saving time by just sliding a switch. The built-in clock chip with battery means it survives power outages. It has a simple voltage regulator circuit because it needs to be powered by a wall-plug, as the LEDs drain a battery pretty fast.

By the time I finished I had used almost every pin on the processor. The sketch demonstrates:

  • Multiplexing an LED display
  • Generating sounds by manually pulsing a speaker
  • An interrupt for handling the Cancel button
  • Talking to the DS1307 chip using I2C
  • Handling common-anode or common-cathode LEDs
  • Timed events (turning the alarm off after 15 minutes)

Very nice! Just the sort of thing I wish I had the gumption to put together.

Thats a cool clock, much better than the standard one thats inside my Nokia E72 Navigator

Cool project. All done with wire wraps. I just started using wire wrapping and I love it. Just forgot one relay output on your board: to shenanigan. ]:smiley: :sleeping:

Wow, Nick! That's terrific! I've got all those parts and I've been wanting to try a stand-alone project like this. Thanks for sharing.

Thanks everyone!

Just to cost it all:

  • 7-segment display: $4
  • Atmega328: $6
  • DS1307 breakout board from Adafruit: $18 (however similar one for $7.90 from Futurlec)
  • Switches: $2 each approx
  • LM7805: $5
  • Buzzer: $1.50
  • 16 MHz resonator: $0.80

Plus a few other small parts, the board, wires, etc.

But the fun thing is, you probably have the parts lying around anyway. :slight_smile:

Excellent point to point wiring technique. Very nice and clean design.

Wow, you guys get raped for material costs down under!

Nice job, Nick! I'm a clock fan myself. Still in the breadboard phase here but thinking towards something more permanent. I'm storing time zone offsets and DST adjustment rules in EEPROM, setting the RTC to UTC, and doing UTC-to-local conversion before sending the time to the display. Might save a couple bucks on the switch :wink:

I made different clocks back in college - transformer to get voltage down to a rectifiable voltage to make DC, dividing down the mains to make 1Hz. One design had 60 LEDs in an outer circle for minutes, 12 in an inner circle for hours. Learned about switch bounce on that one too.
I still have the board for it, covered in dust in a box, chips pulled out for a later project.
The mix of hardware/software that uCs bring to the table make things a lot easier to bring to completion without a big pile of chips.

Thanks for all the complimentary remarks everyone. :slight_smile:

Wow, you guys get raped for material costs down under!

Yes, I'm starting to feel that more and more. There are quite a few things which I can buy 10 of overseas for the price of one here.

I'm storing time zone offsets and DST adjustment rules in EEPROM ...

Well I was tempted, and of course it could be changed. However the government here keeps changing the rules. Something comes up like the Commonwealth Games, and they bring DST forwards or back a week or two.

My ultimate goal would be a heap of clocks that keep reasonably good time, and then a GPS-based "central clock" that gets highly accurate time (eg. daily) and then updates all the other clocks with a radio transmission to them. And that central clock could keep track of daylight savings time as well.

I was coordinating my house clocks using a NIS server until....it was down for several hours. I'm a bit of a nut about having the little machines monitor their own operation and reboot as necessary and when the NIS server went down, I lost my clock because it rebooted at the end of every retry interval. That prompted me to get a (relatively) cheap GPS module and take time from the satellites. That is working really, really well. In my case I provide the time from a single clock over my ethernet network and a XBee broadcast. That way I can sync devices based on either protocol. The little GPS module has a RTC in it too so I don't have to be as careful about reboots.

Your clock is a really cool device. Doing it from the ground up is impressive and fun. I would have made the cancel button about 100% larger though; my aim is bad in the morning.

I have a similar goal: every clock in every appliance (and standalone, too) should be able to keep reasonable time on its own, but should be capable of "listening" (I was thinking power line comm, like X-10) for a reliable source clock. Then you'd need only one "master" clock in a house, although every standalone clock should be able to be a master. That would give everyone the flexibility to even have a cheap clock be the master, but they'd only have to set one clock at home. When DST changes, I have about 15 clocks that have to be touched. Aren't we living in the 21st century?

For the experts here, what would you guess it would cost to add that bit of circuitry to an appliance -- essentially a minimalist X-10 listening circuit?

About $4.80.
RLP434 from laipac.com
or similar receiver if appliance is equipped to accept serial data with the new time.
http://www.laipac.com/easy_434a_eng.htm

Cool, though I believe that's the wireless module that would go with Nick's idea. I was curious about an X-10 like power line comm. system. I just think that a standard for the receiver could be made and published, and implemented for short money (my un-educated guess would be less than $2 in the kinds of volumes manufacturers do) on each appliance, but the value add, esp. across an installed base, would be huge.

CrossRoads:
I made different clocks back in college - transformer to get voltage down to a rectifiable voltage to make DC, dividing down the mains to make 1Hz. One design had 60 LEDs in an outer circle for minutes, 12 in an inner circle for hours. Learned about switch bounce on that one too.
I still have the board for it, covered in dust in a box, chips pulled out for a later project.
The mix of hardware/software that uCs bring to the table make things a lot easier to bring to completion without a big pile of chips.

The frequency may not work in all parts of the world (50/60Hz difference) :slight_smile:

BTW, did you do Charlie-plexing on the 60 LEDs?

Nope. Just had a few demux type chips, 74154 or 74150, that kind of part.
Was all built from scratch using 74xx logic. Maybe 74LS. Point to point soldering on non-copper clad perfboard and PCB mount sockets expoxied in place, or maybe held in place via the decoupling caps. Crude looking wiring job, did the best I could with materials I could scrounge/afford as a poor college kid. My designing/building is way better these days 8)

Made this clock the other day as it was the only thing I could understand, it was simple and I had parts. Hats off to Nick for passing on the info so clearly. I did find one problem. The center digit segments (SEGG) were not lighting properly and the whole thing seemed buggy (like a bad ground or a pin floating) but I could not put my finger on it. Finally I found the trouble. I cannot explain the "why" but apparently having the SEGG on pin13 is not good in this case. I noticed the SEGG in digit 2 flash as I uploaded, it was in sync to the led on pin13 on my boarduino. So, I switched the alarm led and SEGG pins, pin8 and pin 13, and it fixed the problem.

I also have a question. I'm not a programmer (I just started using Arduino IDE this week and I have no previous experience beyond Basic stamp and lighting leds) so bear with me on my lack of proper usage of terms etc.

Question: My display has the 4 decimal points AND a colon. The colon is treated like another digit as I understand things. I can't figure out how to flash it instead of the decimal point. I think I need another output pin and then I'm lost on the code although it looks like it has something to do with the switch statements/functions/procedures? Any advice would be helpful and thanks again.

Do you have a link to the part? Does it have 8 segments (A to G, DP and colon)?

If so, you probably need to wire the colon (and a resistor) to an extra spare output (if you can find one). Then in the digit function turn it on or flash it in a similar way to the way it is done for the DST dot.

My plan is to use a shift register and gain some extra pins, when I can figure it out. I don't understand how the digit function works either so I'll just have to keep at it.

display datasheet link--www.adafruit.com/datasheets/BL-Q56C-43.pdf

LED_7_segment.png