I wouldn't call an if-statement a loop, if that's what you mean. The "loop" in your code is the while-loop that starts at the top of the readrtc function.
Anyway, you made a good attempt. First, remove the "&& (snooze==0)" from the first part of the if-statement. I'll show you where to put that instead. We'll move the buffer condition down as well.
So when the buzzer is activated, it's either the first time or the second time that alarm has activated. If it's the first time, we want to do the snooze, which adds 5 minutes and turns off the alarm. You were very close with your code:
Code:
if ( (clkmin==alarmMin) && (clkhrs==alarmHrs) )
{
buzzer=1;
if ( (buffer==1) && (snooze==0) )
{
alarmMin+=5;
snooze=1;
buzzer=0;
}
I replaced "motion" with "buffer" to keep your code consistent. In your code, "motion" and "buffer" are essentially the same thing, so use one or the other. Not both. The first time the alarm is activated, snooze is still 0, so that's what it should check for. Once inside the if-statement, then you're adding 5 minutes and starting the snooze. So then you set snooze equal to 1. Then, of course, you need to turn off the buzzer by setting it equal to 0. Notice you don't need to do anything with the "buffer" variable here. That's because you already take care of that higher in your code.
Next, you take care of the else case. This is the second time the alarm has activated. This time, you don't want to snooze and you just want the buzzer to turn off:
Code:
else if ( (buffer==1) && (snooze==1) )
{
alarmMin=99;
alarmHrs=99;
buzzer=0;
}
Here, I set alarmHrs and alarmMin to 99 because the clock will never match those values. Therefore, the alarm will not activate again. The buzzer turns off and that's it.