Change when will the alarm trigger

So i found a time alarm which i think can be used for my project

But i am having a question, how to change the value of an already defined alarm, please look at my sketch first (i just tweak it a little)

//This sketch  triggers daily alarms at 8:30 am and 17:45 pm.
//A Timer is triggered every 15 seconds, another timer triggers once only after 10 seconds.

#include <Time.h>
#include <TimeAlarms.h>

byte ID = 0;
void setup()
{
  Serial.begin(9600);
 setTime(8,29,0,1,1,10); // set time to 8:29:00am Jan 1 2010
 // create the alarms 
 Alarm.alarmRepeat(8,30,0, MorningAlarm);  // 8:30am every day
 Alarm.alarmRepeat(17,45,0,EveningAlarm);  // 5:45pm every day 
   
 ID = Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds    
 Alarm.timerOnce(10, OnceOnly);          // called once after 10 seconds 
 
}

void  loop(){  
 digitalClockDisplay();
 
 Serial.println(ID); // will print 2
 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");
 
}

void EveningAlarm(){
 Serial.println("Alarm: - turn lights on");           
}

void Repeats(){
 Serial.println("15 second timer");         
}

void OnceOnly(){
 Serial.println("This timer only triggers once");  

}


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);
}

So, how to change the each 15 sec trigger to for example each 30 sec as i am trying to make the alarm time can be changed by user input.

Thanks again to the forum and its awesome members :slight_smile:

I guess that you can change the repetition interval in ID = Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds  

well it's by sketch then. By mean of user input, i need it so that at first its 15 sec interval by default And then it can be changed by user without changing it's alarm ID I intend to use it with button for input

Because if not there will be two alarm, one each 15 sec and 30 sec.

You have the ID of the alarm. If the user wants to change the interval, delete the existing alarm (which you can because you have its ID), and create another one.

How will the user change the interval?

that is the part where i got confused, how to use that ID to change or delete the alarm As whenever i google it, i cannot found the syntax or similar things with mine.

How user change the interval, for now its like this By button input make it so that the value is 30 save the value to interval and then

Alarm.timerRepeat(interval, Repeats);

how to use that ID to change or delete the alarm

 ID = Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds
 .
 .
 .
 Alarm.free(ID); // That timer no longer exists
 ID = Alarm.timerRepeat(30, Repeats); // Now, it will go off every 30 seconds

heya i tried it and it does free the alarm and replace it with new alarm. So the ID is still 2, which is good

Thanks for this PaulS You made my day