Arrch:
so it sounds like there is another issue with another part of your code, then.
Maybe I put your snippet in the wrong place?
long switchPinsWaitTime = 30000; //30 seconds
static unsigned long switch_timestamp1 = 0;
if(value2 && switch_timestamp1 && (millis() - switch_timestamp1) >= switchPinsWaitTime)
{
// playTone(100, 1000);
// playTone(100, 3000);
// playTone(100, 1000);
// playTone(100, 3000);
switch_timestamp1 += 60000;
}
else if (!switch_timestamp1 && value2)
{
//The !switch_timestamp1 is to make sure we don't refresh the timer if the switch remained on.
//The pin just changed to on, start the timer
switch_timestamp1 = millis();
}
else if(!value2 && switch_timestamp1)
{
//Switch went off, while timer was running, disable the timer
switch_timestamp1 = 0;
}