countdownTimer without LCD

Hello, how to create countdown timer for my project?

I used: UNO, relay module, IR sensor.

#include <IRremote.h>
#include <IRremoteInt.h>

int Pwr = A1; // LED
boolean state = 0;

//IR Receiver Module Pin and variable
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
  pinMode(Pwr, OUTPUT); //
  irrecv.enableIRIn(); //
}

void loop(){
  if(irrecv.decode(&results)){ 
    if(results.value == 0xFF){  
      state = !state; 
    }
    digitalWrite(Pwr, state); // 
    irrecv.resume();
  }
}

This code is work ), but i want to add countdown timer: 5, 10,15 minute. Thank's.

You can use millis() to measure elapsed time.

I read about millis(), but write correct program I cannot ((( May be little example?

My code

#include <IRremote.h>
#include <IRremoteInt.h>

int Pwr = A1; // LED
unsigned long time; //Переменная для  установки  времени
int count_time; //Число нажатий;

boolean state = 0;

time = 0;
count_time=0;

//IR Receiver Module Pin and variable
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
  pinMode(Pwr, OUTPUT); // Вывод Pwr выход
  irrecv.enableIRIn(); //Старт ИК-приёмника
}

void loop(){
  if(irrecv.decode(&results)){ // Декодирование принятого сигнала по ИК  
   
   if(results.value == 0xAA){  //если  нажата кнопка с кодом АА, тогда  выполнить
		digitalWrite(Pwr, state); // включаем реле
		state = !state; 
		time(millis(10000)){ //10 секунд ждем 
			digitalWrite(Pwr, state); // выключаем реле
			state = !state; 
		}
		count_time =1;  // 1-е нажатие  на кнопку
	}
	
	 if((results.value == 0xAA) &&(count_time =1)){  //если уже была нажата кнопка с кодом АА, тогда  выполнить
		digitalWrite(Pwr, state); // включаем реле
		state = !state; 
		time(millis(20000)){ //20 секунд
			digitalWrite(Pwr, state); // выключаем реле
			state = !state; 
		}
		count_time =2; // 1-е нажатие  на кнопку
	}
	
	// и т.д. для 3-4 нажатий
	
	if(results.value == 0xFF111){ // Код кнопки POWER    
      state = !state; 
    }
    digitalWrite(Pwr, state); // Пин Pwr 
    irrecv.resume();
  }

}

But, this code not correct ((

I read about millis(), but write correct program I cannot ((( May be little example?

See Using millis() for timing. A beginners guide and look at the BlinkWithoutDelay example in the IDE.

UKHeliBob:
See Using millis() for timing. A beginners guide and look at the BlinkWithoutDelay example in the IDE.

Thank's

unsigned long time; //Переменная для  установки  времени
int count_time; //Число нажатий;

time = 0;
count_time=0;

As you can tell by the error messages: You can't do that. You can't put an assignment statement outside a function. If you want to initialize a global variable you can do that in the declaration:

unsigned long time = 0; //Переменная для  установки  времени
int count_time = 0; //Число нажатий;