I was recently trying to make a circuit so that when I press a button on an infrared remote, it would make a servo turn, however the code isn't working. Heres the code:
#include <Servo.h>
#include <IRremote.h>
#define Button_1 0xE718FF00
#define Button_2 0xAD52FF00
IRrecv IR(13); // Im using the pin 13
decode_results results;
int servoPin = 3;
// Create a servo object
Servo Servo1;
void setup(){
Serial.begin(9600);
IR.enableIRIn();
Servo1.attach(servoPin); // We need to attach the servo to the used pin number
}
void loop(){
if (IR.decode()){
Serial.println(IR.decodedIRData.decodedRawData, HEX);
IR.resume();
switch(results.value) {
case Button_1 : Servo1.write(45); break;
case Button_2 : Servo1.write(0); break;
}
}
}
This code decodes Hex just fine; however, when the correct hex codes are inputted, the servo doesn't move. Help!
#include <ServoTimer2.h>
#include <IRremote.h>
#define Button_1 0xE718FF00
#define Button_2 0xAD52FF00
IRrecv IR(13); // Im using the pin 13
decode_results results;
int servoPin = 3;
// Create a servo object
ServoTimer2 Servo1;
void setup(){
Serial.begin(9600);
IR.enableIRIn();
Servo1.attach(3); // We need to attach the servo to the used pin number
}
void loop(){
if (IR.decode()){
Serial.println(IR.decodedIRData.decodedRawData, HEX);
IR.resume();
switch(results.value) {
case Button_1 : Servo1.write(750); break;
case Button_2 : Servo1.write(1500); break;
}
}
}
If via the Arduino regulator, not a good idea for driving any servo.
Which I asked for a "complete" circuit diagram.
i.e. do you have a higher voltage to the Vin ????