Its great the function is called but but
My arduino does not have constant power supply I mean it is not switch on 24/7
So when the arduino is switch off and the alarm gets missed my function doesnt know whether it was called or not
In simple words
I need my missed alarm
Or
When I say keep a switch on from 9am to 10am
Alarm.alarmOnce(9, minutes, seconds, switchon);
Alarm.alarmOnce(10, minutes, seconds, switchoff);
It simply doesnt work when my arduino is off at 9am
And when I get my power back at9:10am the switch is suppose to be ON but its not on because it has missed its moment, or pulse
Plz help
Suggest me anything
Plz plz plz its urgent and my project depends on it
sorry bro am new here
second my question is so generic that in timealarms.h library how will i get my missed alarms, anyways the code is attached, not yet completed,
/*
* TimeAlarmExample.pde
*
* This example calls alarm functions at 8:30 am and at 5:45 pm (17:45)
* and simulates turning lights on at night and off in the morning
* A weekly timer is set for Saturdays at 8:30:30
*
* A timer is called every 15 seconds
* Another timer is called once only after 10 seconds
*
* At startup the time is set to Jan 1 2011 8:29 am
*/
// Questions? Ask them here:
// http://forum.arduino.cc/index.php?topic=66054.0
#include <TimeLib.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
RTC_DS1307 RTC;
int ho,mi,se,mo,ye,da,dd;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
while (!Serial) ; // wait for Arduino Serial Monitor
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
// Print a message to the LCD.
Serial.println("RTC is running!");
delay(1000);
DateTime now = RTC.now();
setTime(now.hour(),now.minute(),now.second(),now.day(),now.month(),now.year()); // set time to Saturday 8:29:00am Jan 1 2011
// create the alarms, to trigger at specific times
Alarm.alarmRepeat(1,43,0, MorningAlarm); // 8:30am every day
Alarm.alarmRepeat(1,43,14,EveningAlarm); // 5:45pm every day
Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday
// create timers, to trigger relative to when they're created
Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds
}
void loop() {
DateTime now = RTC.now();
ye=now.year();
mo=now.month();
da=now.day();
ho=now.hour();
mi=now.minute();
se=now.second();
dd=now.dayOfTheWeek();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(ho);
lcd.print(':');
lcd.print(mi);
lcd.print(':');
lcd.print(se);
lcd.setCursor(0,1);
digitalClockDisplay();
Alarm.delay(1000); // wait one second between clock display
}
// functions to be called when an alarm triggers:
void MorningAlarm() {
Serial.println("Alarm: - turn lights off");
lcd.print("morning alarm");
delay(2000);
}
void EveningAlarm() {
Serial.println("Alarm: - turn lights on");
lcd.print("evening alarm");
delay(2000);
}
void WeeklyAlarm() {
Serial.println("Alarm: - its Monday Morning");
}
void ExplicitAlarm() {
Serial.println("Alarm: - this triggers only at the given date and time");
}
void Repeats() {
Serial.println("15 second timer");
lcd.print("15sec alarm");
delay(2000);
}
void digitalClockDisplay() {
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits) {
Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);
}
[code]
In the current code the RTC is serving no purpose but displaying the time on the LCD. TimeAlarms run off of millis()-based time provided by TimeLib. The later can be synced to the RTC with the setSyncProvider() function. But, that's not done in this code.