Arduino Alarm-Clock

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
liss31
 
Posts: 4
Joined: Sat Mar 07, 2015 11:18 am

Arduino Alarm-Clock

Post by liss31 »

Hi guys,

I am working on a project for a class and we are in need of an arduino based alarm clock that goes off at specified times. I have bought me the adafruit clock kit and built it so http://www.doctormonk.com/2012/08/revie ... d-rtc.html. The clock works. Now i have the problem to program the alarm. I hope you can help me there.

Thanks

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Alarm-Clock

Post by adafruit_support_rick »

You want to use the Time Library and the TimeAlarms Library
http://www.pjrc.com/teensy/td_libs_Time.html
http://www.pjrc.com/teensy/td_libs_TimeAlarms.html

Next, have a look at this thread, which shows you how to initialize the RTC and synchronize it with the onboard Arduino clock.
viewtopic.php?f=25&t=49423&hilit=+setsy ... er#p346369

The thing to remember is that the Time library works with the built-in Arduino clock. The setSyncProvider function keeps the Arduino clock synchronized with the RTC. The synchronization happens when the you call Time library functions to get the current time or date.

User avatar
liss31
 
Posts: 4
Joined: Sat Mar 07, 2015 11:18 am

Re: Arduino Alarm-Clock

Post by liss31 »

Thanks for your quick response.
I must say that I´m not the best in this area and I´m not understand the thread. I dont know what and how to do that.
I hope you can help me again.

Thanks

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Alarm-Clock

Post by adafruit_support_rick »

OK. Then the simplest thing to do is to keep comparing the current time with the alarm time in loop(). When they are equal, fire the alarm.

User avatar
liss31
 
Posts: 4
Joined: Sat Mar 07, 2015 11:18 am

Re: Arduino Alarm-Clock

Post by liss31 »

I tried it, but unsuccessfully. Do you have an example sketch for me. The sketch must be based on the program code for the time, that i put in the first post.
It is really important for my school note.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Alarm-Clock

Post by adafruit_support_rick »

post the code you have.

User avatar
liss31
 
Posts: 4
Joined: Sat Mar 07, 2015 11:18 am

Re: Arduino Alarm-Clock

Post by liss31 »

Here is the code for the clock.

Code: Select all

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "RTClib.h"

RTC_DS1307 RTC;
Adafruit_7segment disp = Adafruit_7segment();

int getDecimalTime()
{
  DateTime now = RTC.now();
  int decimalTime = now.hour() * 100 + now.minute();
  return decimalTime;
}

void setup() 
{
  Wire.begin();
  RTC.begin();
  if (! RTC.isrunning()) 
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  disp.begin(0x70);
}

void loop() 
{
  disp.print(getDecimalTime());
  disp.drawColon(true);
  disp.writeDisplay();
  delay(500);
  disp.drawColon(false);
  disp.writeDisplay();
  delay(500);
}

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Alarm-Clock

Post by adafruit_support_rick »

I don't see anything about the alarm in there. You said that you tried it and it didn't work. Can I see that code?

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”