Arduino alarm clock with Phi-1 shield
November 25, 2010 16 Comments
ATTENTION:You are reading an old post. The hardware and code mentioned here have long been upgraded.
Visit this link:
I’ve thought about this for a while, make an alarm clock and be waken up by my own creation (I guess babies will do but they wake you too early).
I will need a real time clock chip (DS1307) to keep the time, arduino to display it on an LCD or LED matrix. I also need a buzzer to make some noise and a high-brightness LED to make flashy lights. Besides I need to program it so that it takes user input: adjust the time and date, set alarm with various settings “weekday, weekend, daily, once, off”. More importantly, I need to make sure a special key stops the alarm so I can get back to sleep!
Here is a flow chart of the alarm clock:
Well, let’s get to work. I’d like to get the “adjust clock” to work first. I know just the right tricks to do the job. I took a part of my other project, which is the human machine interface, added a few features, and poured it into the adjust clock and alarm. The functions simply take an initial value, its upper and lower boundary, and step. It renders the numbers or information and takes user inputs like up and down and confirm. It traps until the user finishes with the input and returns the entered value. The rest of the work is just labor.
The alarm function isn’t too hard either. You take an alarm time and compare with current time, then decide if the alarm criterion fits with the day of the week. I wrote a simple function within() to determine if the current day is within the alarm’s criterion, like Thursday is both daily and weekday.
The alarm isn’t too hard either. I picked a tone that is close to the clock I used years back and make it turn on and then off repeatedly four times. That was the alarm.
We will construct a fully-interactive arduino powered alarm clock with the following functions:
1. Displays the time and date
2. User adjustable time and date
3. User settable alarms with various settings “weekday, weekend, daily, once, off”, with buzzer and flashy led to wake you up.
4. More importantly, a special key that stops the alarm so you can get back to sleep!
5. Use the alarm function to power any shenanigans you want against your sleepy head 🙂
We will need the following parts:
We will need the following tools:
1. A soldering iron. Anything from radioshack will work just fine. I use a set that is $8 with the iron and a few tools including some solder.
2. 45 degree cutter for electrical cords, to trim after you’re done solder. You can buy one from radioshack or other places.
3. Optional third hand for holding circuit board. I can just lay the board down and solder it
4. Masking tape to hold down parts to be soldered
Code:
Alarm clock (buzzer and LED) This program is a fully-functional alarm clock. You will find it more complex than the basic clock. If you can’t understand, try the Clock display first.
For more information on Phi-1 shield, read its webpage!
Here is a video:
Looks like you are an expert in this field, you got some great points there, but you’ll want to add a facebook button to your blog. I just bookmarked this article, although I had to complete it manually. Simply my $.02 🙂
– Daniel
Thanks Daniel. I will look into adding the button tonight!
Just added a link on my Phi-1 shield page. Will add to every post soon!
Hi,
your clock is very nice,
but can you add few things
I want set alarm end time minute increments and
I want two separate outputs
I can do that, will find time:)
What do you mean by two separate outputs? Alarms?
There are two outputs buzzer and led, I want use two outputs to control various devices (relays) different time
Thank you very much for an awesome shield. It was a snap to assemble but I am having a bit of difficulty with the buzzer. The buzzer in my kit appears to be somewhat different from the one in the video…maybe piezo…not sure. Bottom line is I cannot get the buzzer to buzz even though the L.E.D. will flash. Everything else works beautifully. I followed directions to the letter (outstanding detail by the way) and, yes, the buzzer is oriented with the positive lead at the top. Thank you very any help you can provide.
Hey, thanks for purchasing the shield. Could you send me a picture of the buzzer showing it marking on the side and the assembled board, top and bottom? I’ll email you my email address.
Thank you so very much for replying. I strained a neuron and failed to notice I had not installed the buzzer resistor (R2). I noticed my error when I zoomed in on Figure 2 under paragraph 10 of your build guide. Apologies for my error which I literally just discovered.
Dipmicro is currently packaging a “Magnetic Transducer PB-1226PEAQ by Mallory” as the buzzer for your shield. The buzzer works perfectly fine (as I have just now installed R2 and tested the unit) however it does not exactly match the image of the buzzer in your build photo. Your build guide is very well written and everything was very easy to set up…minus my error.
I am sorry to see DipMicro is out of stock on your shield as I have already told several people about it. Do you have an idea as to when it will be back in stock…or the status of the Phi-2? Again, thank you very much for your reply and for developing an awesome shield.
Have an OUTSTANDING day!
P. Shay
Hi liudr
I have a
Arduino Duemilanove
Ide Arduino 1.0.3
Alarm clock (buzzer and LED) (phi_1_test_alarm_clock_v3.zip )
When I verify I get the following message :
What am I doing wrong ?
Takis
From Athens – Greece
In file included from buttons.cpp:8:
buttons.h:28: error: ‘byte’ does not name a type
buttons.h:29: error: ‘byte’ does not name a type
buttons.h:30: error: ‘byte’ does not name a type
buttons.h:31: error: ‘byte’ does not name a type
buttons.h:32: error: ‘boolean’ does not name a type
buttons.h:34: error: ‘byte’ does not name a type
buttons.h:40: error: expected `)’ before ‘p’
buttons.h:41: error: expected `)’ before ‘p’
buttons.cpp:9: error: expected `)’ before ‘p’
buttons.cpp:20: error: ‘byte’ does not name a type
buttons.cpp: In member function ‘void buttons::do_up()’:
buttons.cpp:52: error: ‘holding’ was not declared in this scope
buttons.cpp:53: error: ‘counts’ was not declared in this scope
buttons.cpp:54: error: ‘pin’ was not declared in this scope
buttons.cpp:54: error: ‘digitalRead’ was not declared in this scope
buttons.cpp:54: error: ‘pressed’ was not declared in this scope
buttons.cpp:56: error: ‘stat’ was not declared in this scope
buttons.cpp:57: error: ‘millis’ was not declared in this scope
buttons.cpp: In member function ‘void buttons::do_debounce()’:
buttons.cpp:63: error: ‘pin’ was not declared in this scope
buttons.cpp:63: error: ‘digitalRead’ was not declared in this scope
buttons.cpp:63: error: ‘pressed’ was not declared in this scope
buttons.cpp:65: error: ‘millis’ was not declared in this scope
buttons.cpp:65: error: ‘stat’ was not declared in this scope
buttons.cpp:68: error: ‘stat’ was not declared in this scope
buttons.cpp: In member function ‘void buttons::do_down()’:
buttons.cpp:74: error: ‘pin’ was not declared in this scope
buttons.cpp:74: error: ‘digitalRead’ was not declared in this scope
buttons.cpp:74: error: ‘pressed’ was not declared in this scope
buttons.cpp:76: error: ‘stat’ was not declared in this scope
buttons.cpp:76: error: ‘holding’ was not declared in this scope
buttons.cpp:80: error: ‘holding’ was not declared in this scope
buttons.cpp:82: error: ‘counts’ was not declared in this scope
buttons.cpp:88: error: ‘millis’ was not declared in this scope
buttons.cpp:90: error: ‘stat’ was not declared in this scope
buttons.cpp:91: error: ‘counts’ was not declared in this scope
buttons.cpp:95: error: ‘stat’ was not declared in this scope
buttons.cpp: In member function ‘void buttons::do_released()’:
buttons.cpp:102: error: ‘stat’ was not declared in this scope
buttons.cpp:103: error: ‘holding’ was not declared in this scope
buttons.cpp:104: error: ‘counts’ was not declared in this scope
buttons.cpp: In member function ‘void buttons::do_held()’:
buttons.cpp:109: error: ‘holding’ was not declared in this scope
buttons.cpp:110: error: ‘pin’ was not declared in this scope
buttons.cpp:110: error: ‘digitalRead’ was not declared in this scope
buttons.cpp:110: error: ‘pressed’ was not declared in this scope
buttons.cpp:112: error: ‘stat’ was not declared in this scope
buttons.cpp:113: error: ‘millis’ was not declared in this scope
buttons.cpp:117: error: ‘stat’ was not declared in this scope
scope
Takis,
I think you are using a very old piece of code. It was for phi-1 shield that I discontinued a year ago. The new code for phi-2 shields are all on my google code page:
http://code.google.com/p/phi-prompt-user-interface-library/downloads/list
The current version of the alarm clock is v6.
Can you provide me a link where you found this code, so I can remove that link? Thanks.
The file is : Phi_1_test_alarm_clock_v3. I found this page:
http://liudr.wordpress.com/2010/11/25/arduino-alarm-clock-with-phi-1-shield/#comments
Alarm clock (buzzer and LED) = Phi_1_test_alarm_clock_v3.zip ==
http://www.mediafire.com/?dstpv5sod7r9ew4
now I downloaded and ran the Phi_2_project_alarm_clock_v6.zip
with Ide Arduino 1.0.3
and !!!! Error Compiling
When I verify I get the following message :
What am I doing wrong ?
I apologize for the long text, but if you want send me a message in my gmail not to employ and this page with long texts.
Error Compiling
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307′:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:13: multiple definition of `DS1307::DS1307()’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:13: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307′:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:13: multiple definition of `DS1307::DS1307()’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:13: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::set_sram_byte(unsigned char, int)’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:204: multiple definition of `DS1307::set_sram_byte(unsigned char, int)’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:204: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::set_sram_data(unsigned char*)’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:181: multiple definition of `DS1307::set_sram_data(unsigned char*)’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:181: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::save_rtc()’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:37: multiple definition of `DS1307::save_rtc()’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:37: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::start()’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:159: multiple definition of `DS1307::start()’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:159: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::stop()’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:151: multiple definition of `DS1307::stop()’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:151: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::set(int, int)’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:90: multiple definition of `DS1307::set(int, int)’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:90: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::get_sram_byte(int)’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:194: multiple definition of `DS1307::get_sram_byte(int)’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:194: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::get_sram_data(unsigned char*)’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:167: multiple definition of `DS1307::get_sram_data(unsigned char*)’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:167: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::read_rtc()’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:19: multiple definition of `DS1307::read_rtc()’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:19: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::get(int, unsigned char)’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:59: multiple definition of `DS1307::get(int, unsigned char)’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:59: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::min_of_day(unsigned char)’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:143: multiple definition of `DS1307::min_of_day(unsigned char)’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:143: first defined here
PHI_2_PROJECT_ALARM_CLOCK_V6\DS1307.cpp.o: In function `DS1307::get(int*, unsigned char)’:
c:\ARDUINO-1.0.3\libraries\PHI_2_PROJECT_ALARM_CLOCK_V6/DS1307.cpp:50: multiple definition of `DS1307::get(int*, unsigned char)’
DS1307.cpp.o:C:\DOCUME~1\dbekkos\LOCALS~1\Temp\build4545642446000405416.tmp/DS1307.cpp:50: first defined here
Thanks for the link. That post is ancient. I’ll remove the link. I first used mediafire to host my project codes and later realized that the website is like a spam or scam so left it for google code. It seems like you put the files in the wrong spots. The project code goes in arduino sketchbooks, NEVER the libraries. Also I wonder if you installed the phi_prompt or phi_interfaces libraries correctly.
Hi , and thanks liudr
Now I run the Phi_2_project_alarm_clock_v6.zip
With Ide Arduino 1.0.3 and all are ok.
We are now going to plan the breadboard , to do the actual test.
I will notify
Thanks
panos_Athens
You are welcome panos! Glad to know you resolved the issue. If you want to share any details of your project in the future, let me know.
Pingback: Fix Arduino Error Byte Has Not Been Declared Windows XP, Vista, 7, 8 [Solved]