#include <IRremote.h>
#include <Servo.h>
Servo robot_aram;
int IR_input = 5;
IRrecv IR_signal (IR_input);
void setup() {
robot_aram.attach(3);
IR_signal.begin(IR_input);
Serial.begin(9600);
// put your setup code here, to run once:
}
void loop() {
if(IR_signal.decode())
verify();
IR_signal.resume();
}
void verify()
{
switch(IR_signal.decodedIRData.command)
{
case 162:
monitor("POWER ");
robot_aram.write(90);
break;
case 226:
monitor("MENU ");
robot_aram.write(0);
break;
case 34:
monitor("TEXT ");
robot_aram.write(90);
break;
case 2:
monitor("PLUS ");
robot_aram.write(0);
break;
default:
monitor("OTHER ");
robot_aram.write(90);
}
}
void monitor(char* button_name)
{
Serial.print(button_name);
Serial.println("button is pressed");
Serial.print("code: ");
Serial.println(IR_signal.decodedIRData.command);
}