set alarm time for different week days

hi mem!
i am facing some problem in setting alarm time on different week days will you please guide me …i have asked my questions related to this on the following link
http://forum.arduino.cc/index.php?topic=255715.0
…, but due to some reason my that id isnt working thats why ii have created a new thread to ask a new question related to that one …i have attached my full arduino code over here and i hope you are very fimiliar with this code … now the question is that in this program i used to set the alarm time through serial command , like i send the hour and minute to set the time for alarm but now i want to set the time for different weekdays …like i want to set the alarm time for monday 8:00am, tuesday 9:00am ,wed 10:00am… i hope you have understand that what i am trying to say…like i want to set alarm time for different weekdays through serial command … thanks in advance mem as you had already helped me a lot and again need your favour

simpleAlam.ino (1.98 KB)

i want to set the time for different weekdays

Then use this format

Alarm.alarmRepeat(dowMonday, 9,15,0, MondayMorningAlarm);

thanks for your reply sir UKHeliBob… but how should i set this week day through serial command

ashali1234:
i have asked my questions related to this on the following link

Cross-post removed. Please do not do that again.

but how should i set this week day through serial command

dowSunday is 1 and dowMonday is 2 etc so all you need to do is to read a single digit into a variable and use it in setting the alarm. The variable name does not need to be dowXXXX

thanks UKHeliBob… i have tried what you have told me but its not working … will you please tell me what sort of mistake i am making in this …here is my whole code

#include <Time.h>  
#include <Wire.h>  
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t
#include <TimeAlarms.h>
#define PJG_DATA 7
#define INT_SLAVE 'I'
byte hourStart1 = 0;
byte minuteStart1 = 0;
byte weekStart1 = 0;
AlarmID_t alarmStart1; //ID for interval Slave 1
int led=13;
#define AlarmDHMS(D,H,M,S)  (((D-1)* SECS_PER_DAY)  +  (H * SECS_PER_HOUR) + (M* SECS_PER_MIN)  + S)
void setup()  {
  Serial.begin(9600);
  while (!Serial) ; // wait until Arduino Serial Monitor opens
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if(timeStatus()!= timeSet) 
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");   
}
void loop()
{
  if (timeStatus() == timeSet) {
    digitalClockDisplay();
  } else {
    Serial.println("The time has not been set.  Please run the Time");
    Serial.println("TimeRTCSet example, or DS1307RTC SetTime example.");
    Serial.println();
    delay(4000);
  }
  delay(1000);
  if (Serial.available())
  {
    char header = Serial.read();
    if (header == INT_SLAVE)
      Interval();
  }
}
void Interval()
{ int weekStart1 = Serial.parseInt();
  int hourStart1 = Serial.parseInt();
  int minuteStart1 = Serial.parseInt();
  time_t newStart1 = AlarmDHMS (weekStart1,hourStart1, minuteStart1, 0);
  alarmStart1 = Alarm.alarmRepeat( newStart1,Start1); // create the new alarm
  Serial.print("New alarm set for ");
  Serial.print(weekStart1);
  Serial.print(":");
  Serial.print(hourStart1);
  Serial.print(":");
  Serial.println(minuteStart1);
 // setTestTime();  // advance the clock to near the next alarm time
}
void Start1() {
  time_t t = now();
  Serial.print("alarm time is ...");
  
}

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(weekday());
  Serial.print(":");
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

i have also attached the pic of serial monitor …

What do you see if you print newStart1 before setting the alarm ?

UKHeliBob
i saw this 481620
when i send I06:13:47 to set the alarm time to 6 weekday ,13 hour and 47 minute… i have also attached the pic o f serial monitor

The TimeAlarms documentation says the format should be

Alarm.alarmRepeat(dowMonday, 9,15,0, MondayMorningAlarm);

but you are trying to set it with

alarmStart1 = Alarm.alarmRepeat( newStart1,Start1); // create the new alarm

which equates to

alarmStart1 = Alarm.alarmRepeat( 481620, Start1); // create the new alarm

when the value of newStart1 is substituted.

That may be your problem.

timeAlarms.cpp has this function variant which is what would be used if the day of the week were passed explicitly as a parameter

    AlarmID_t TimeAlarmsClass::alarmRepeat(const timeDayOfWeek_t DOW, const int H,  const int M,  const int S, OnTick_t onTickHandler){  // as above, with day of week 
       return create( (DOW-1) * SECS_PER_DAY + AlarmHMS(H,M,S), onTickHandler, IS_REPEAT, dtWeeklyAlarm );      
    }

thanks for your reply UKHeliBob..
actually i am not getting you correctly that what are you saying .. so will you plz tell me that where should i place this statement in my program

AlarmID_t TimeAlarmsClass::alarmRepeat(const timeDayOfWeek_t DOW, const int H,  const int M,  const int S, OnTick_t onTickHandler){  // as above, with day of week 
       return create( (DOW-1) * SECS_PER_DAY + AlarmHMS(H,M,S), onTickHandler, IS_REPEAT, dtWeeklyAlarm );      
    }

so that it works fine

That function does not go in your program. It is part of the TimeAlarms library and will be called when you set a repeating alarm using this format

Alarm.alarmRepeat(dowMonday, 9,15,0, MondayMorningAlarm);

Note how the number and type of parameters in that call match those in the function. Currently in your program you are using
Alarm.alarmRepeat( 481620, Start1);which will cause TimeAlarms to use a different version of the function which does not allow for days of the week. You need to change your program so that the parameters you use match those needed.