#include <IRremote.h>
#include <Servo.h>
int RECV_PIN = 5;
#define code1 4294967295 // แก้ค่าปุ่มกดที่ 1
#define code2 16736925 // แก้ค่าปุ่มกดที่ 2
IRrecv irrecv(RECV_PIN);
decode_results results;
int ircode=0;
Servo myServo1; // Create a "Servo" object called "arm"
Servo myServo2; // Create a "Servo" object called "arm"
int pinMyServo1=10;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
myServo1.attach(pinMyServo1); // Attache the arm to the pin 2
myServo1.write(0); // Initialize the arm's position to 0 (leftmost)
}
void loop() {
// Checks received an IR signal
if (irrecv.decode()) {
ircode = irrecv.decodedIRData.command;
Serial.print("code IR: "+String(ircode));
if (ircode==48){
myServo1.write(90);
}
if (ircode==104){
myServo1.write(0);
}
//translateIR();
//receiver.resume(); // Receive the next value
irrecv.resume();
}
}