Pages: [1] 2   Go Down
Author Topic: Alarm clock from Atmega328 and 7-segment display  (Read 4954 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Arlington, MA, USA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Port Elizabeth, South Africa
Offline Offline
Full Member
***
Karma: 2
Posts: 168
Life's to short to be an adult!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6922
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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-twist smiley-sleep
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley
« Last Edit: June 10, 2011, 05:58:44 pm by Nick Gammon » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3533
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all the complimentary remarks everyone. smiley

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

New River, Arizona
Offline Offline
God Member
*****
Karma: 16
Posts: 907
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Trying to keep my house under control http://www.desert-home.com/

Arlington, MA, USA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Arlington, MA, USA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1] 2   Go Up
Jump to: