#include <IRremote.h>

#define irPin 11        // TSOP OUT pin
#define relayLight 13   // pin you want to control

boolean relState;
long switchButton;
int i = 0;

IRrecv irRecv(irPin);
decode_results irCommand;

void setup()
{
  pinMode(relayLight, OUTPUT);
  Serial.begin(9600);
  irRecv.enableIRIn();
}

void loop()
{

  if (irRecv.decode(&irCommand))
  {
    //Store the first command as the Switch button
    if (i < 1)
    {
      i++;
      switchButton = irCommand.value;
    }

    //If received command is the switchButton command, change the pin output state
    if (irCommand.value == switchButton)
    {
      relState = !relState;
      digitalWrite(relayLight, relState);
    }
    irRecv.resume();
  }
}

