Counter with relay and RF Reset Button

Counter with relay and RF Reset Button for counter

My idea was that example. every 10 minutes, the relay will go high, unless I press a button that resets the counter inside the 10 min. has elapsed.

But I have a little trouble with my code, but it should otherwise be simple, but no.

My code:

#include <RCSwitch.h>
unsigned long time;

int alarmTime = 25;
int countTime = 30;
int resetTime = 35;

int Relay = 12;

RCSwitch mySwitch = RCSwitch();

const int radiopause = 499;

void setup() {
  
  pinMode(Relay, OUTPUT);
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
  }

void loop() {
  
  Serial.print("Time: ");
  time = millis()/1000;
  //prints time since program started
  Serial.println(time);
  delay(250);
//********  
  if (time == alarmTime) { //
  for(int i=0; i<6; i++) {
  tone(8, 440, 500);
  }
  
  if (time == countTime) { //
  noTone(8);
  digitalWrite(Relay, HIGH);
  delay(3000);
  digitalWrite(Relay, LOW);
  delay(100);
  } 
  
  if (time == resetTime) { //
  extern volatile unsigned long timer0_millis, timer0_overflow_count;
  noInterrupts();
  timer0_millis = timer0_overflow_count = 0;
  interrupts();
  }
//*************************************************************************************  
  if (mySwitch.available()) {
    
    int value = mySwitch.getReceivedValue();
  
    if (value == 0) {
      Serial.print("Unknown encoding");
    } else {
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );
  } 
  
//********
  if ( mySwitch.getReceivedValue() == 7618572) { //1. Lightning! - 7618572 - Remote 2 Ext.
  delay(100);
  digitalWrite(Relay, HIGH);
  delay(3000);
  digitalWrite(Relay, LOW);
  delay(100);
  }
  
  if ( mySwitch.getReceivedValue() == 7618563) { //3. Unlock - 7618563 - stop! Remote 2 Ext.
  delay(100);
  extern volatile unsigned long timer0_millis, timer0_overflow_count;
  noInterrupts();
  timer0_millis = timer0_overflow_count = 0;
  interrupts();
  }
  
  delay(radiopause);
  mySwitch.resetAvailable();
  
  }
  }
  }

Regards
Nicolai

I have removed this line:

for(int i=0; i<6; i++) {

#include <RCSwitch.h>
unsigned long time;

int alarmTime = 570;
int countTime = 600;
int resetTime = 605;

int Relay = 12;

RCSwitch mySwitch = RCSwitch();

const int radiopause = 250;

void setup() {
  
  pinMode(Relay, OUTPUT);
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
  }

void loop() {
  
  Serial.print("Time: ");
  time = millis()/1000;
  //prints time since program started
  Serial.println(time);
  delay(250);
//********  
  
  if (time == alarmTime) { //
  tone(8, 440, 500);
  }
  
  if (time == countTime) { //
  noTone(8);
  digitalWrite(Relay, HIGH);
  delay(3000);
  digitalWrite(Relay, LOW);
  delay(100);
  } 
  
  if (time == resetTime) { //
  extern volatile unsigned long timer0_millis, timer0_overflow_count;
  noInterrupts();
  timer0_millis = timer0_overflow_count = 0;
  interrupts();
  }
  
  if (mySwitch.available()) {
    
    int value = mySwitch.getReceivedValue();
  
    if (value == 0) {
      Serial.print("Unknown encoding");
    } else {
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );
  } 
  
  if ( mySwitch.getReceivedValue() == 7618572) { //1. Lightning! - 7618572 - Remote 2 Ext.
  delay(100);
  digitalWrite(Relay, HIGH);
  delay(3000);
  digitalWrite(Relay, LOW);
  delay(100);
  }
  
  if ( mySwitch.getReceivedValue() == 7618563) { //3. Unlock - 7618563 - stop! Remote 2 Ext.
  delay(100);
  extern volatile unsigned long timer0_millis, timer0_overflow_count;
  noInterrupts();
  timer0_millis = timer0_overflow_count = 0;
  interrupts();
  }
  
  delay(radiopause);
  mySwitch.resetAvailable();
  }
  }