#include <IRremote.h>
int IR_input=12;
#include <Servo.h>
Servo gate;
IRrecv IR_fly (IR_input);



void setup() {
   IR_fly.begin(IR_input);
   gate.attach(12);
   pinMode(trig, OUTPUT);
   pinMode(echo, INPUT);
   Serial.begin(9600);

  // put your setup code here, to run once:

}

void loop() {
  if(IR_fly.decode())
  {
    verify();
    IR_fly.resume();
  }
  }
 void verify()
  {
    switch(IR_fly.decodedIRData.command)
    {
      case 162:
      monitor("open gate ");
      gate.write(180)
      break;
      case 226:
      monitor("close gate");
      gate.write(0);
      break;
    
    }
  }
  // put your main code here, to run repeatedly:
void monitor(char*button_name)
{
  Serial.print(button_name);
  Serial.println("button_pressed");
  Serial.println(IR_fly.decodedIRData.command);
}