#include <Servo.h>
#include <IRremote.h>
int Right = 144;
int Left = 224;
int Up= 2;
int Down= 152;
int Reset = 162;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
Servo servo1;
Servo servo2;
int command;
int pos_x = 90;
int pos_y = 90;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
irrecv.enableIRIn();
servo1.attach(10);
servo2.attach(9);
}
void loop() {
// put your main code here, to run repeatedly:
if (irrecv.decode()) {
//Serial.println("Received");
command = irrecv.decodedIRData.command;
button_commands();
irrecv.resume(); // Receive the next value
}
}
void button_commands(){
if(command == Left){
Serial.println(command);
pos_x = pos_x-2;
servo1.write(pos_x);
}
else if(command == Right){
pos_x = pos_x+2;
servo1.write(pos_x);
Serial.println(command);
}
else if(command == Up){
pos_y = pos_y+2;
servo2.write(pos_y);
Serial.println(command);
}
else if(command == Down){
pos_y = pos_y-2;
servo2.write(pos_y);
Serial.println(command);
}
else if(command == Reset){
servo1.write(90);
servo2.write(90);
pos_x = 90;
pos_y = 90;
Serial.println(command);
}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
ir1:GND
ir1:VCC
ir1:DAT
servo1:GND
servo1:V+
servo1:PWM
servo2:GND
servo2:V+
servo2:PWM