Go Down

Topic: Alarm clock from Atmega328 and 7-segment display (Read 6572 times) previous topic - next topic

Nick Gammon

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:

http://www.gammon.com.au/forum/?id=11165

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)

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

tastewar

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

Inprogress

Thats a cool clock, much better than the standard one thats inside my Nokia E72 Navigator
"The really amazing thing is how many people are successful with their Arduino projects considering the fact that so many of them do not have a technical background.  A lot of them seem to try, and succeed with, projects that no sane engineer would even attempt." - floresta commenting on the proper use of LCD displays

liudr

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. ]:D :smiley-sleep:

pdxNat

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.

Nick Gammon

#5
Jun 11, 2011, 12:22 am Last Edit: Jun 11, 2011, 12:58 am by Nick Gammon Reason: 1
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. :)
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

kalum

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

CrossRoads

Wow, you guys get raped for material costs down under!
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Jack Christensen

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  ;)
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nick Gammon

Thanks for all the complimentary remarks everyone. :)

Quote
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.

Quote
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.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

draythomp

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.
Trying to keep my house under control http://www.desert-home.com/

tastewar


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 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?

CrossRoads

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
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

tastewar

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.

Go Up