#include <IRremote.h>


#define IR_RECEIVE_PIN 8

int relay_pin = 10;
int state = 0;

//IRrecv receiver(receiver_pin);
//decode_results output;

void setup()
{  	
  	Serial.begin(9600);
  	IrReceiver.begin(IR_RECEIVE_PIN);
}

void loop()
{
  if(IrReceiver.decode())
  {
    IrReceiver.resume();
    //Serial.println(IrReceiver.decodedIRData.command);
	int value=	IrReceiver.decodedIRData.command;
   Serial.println(value);
    //switch(value)
    if(value==162)
    {
			//case first_key:
			if(state==1)
            {
				digitalWrite(relay_pin, LOW);
				state= 0;
              delay(1000);
			}
          	else
          	{
				digitalWrite(relay_pin, HIGH);
				state=1;
              delay(1000);
            }
          	//break;
			//Serial.println(value);
			//IrReceiver.resume();
        }
    }
}