#include <IRremote.h>
#include <Servo.h>
Servo Robot_arm;
int IR_input = 8;
IRrecv IR_fly(IR_input);
void setup() {
IR_fly.begin(IR_input);
Robot_arm.attach(10);
Serial.begin(9600);
// put your setup code here, to run once:
}
void loop() {
if (IR_fly.decode())
{
verify();
IR_fly.resume();
}
// put your main code here, to run repeatedly:
}
void verify()
{
switch(IR_fly.decodedIRData.command)
{
case 162:
monitor("POWER ");
Robot_arm.write(90);
delay(1000);
break;
case 226:
monitor("MENU ");
Robot_arm.write(135);
delay(1000);
break;
}
void monitor(char*button_name)
{
Serial.print(button_name);
Serial.println("BUTTON is pressed");
Serial.print("CODE :");
Serial.println(IR_fly.decodedIRData.command);
}
}