Controlling a servo with an IR remote

Hello everyone,

I am trying to get my servo to turn when I press a button on a remote. Here is the code (sorry if it is formatted weirdly I made this account today):

#include <IRremote.h> 
#include <Servo.h>
//fwd 9
//bck 7
Servo myservo;
int val;

const byte IR_RECEIVE_PIN = 11;

void setup() {
   Serial.begin(9600);
   Serial.println("IR Receive test");
   IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
   myservo.attach(9);
}

void loop() {
   if (IrReceiver.decode()) {
      Serial.println(IrReceiver.decodedIRData.command, HEX);
      IrReceiver.resume();
   }/*
   if (results.value == fwd) {
    myservo.write(30);
    delay(15);
   }
   if (results.value == bck) {
    myservo.write(0);
    delay(15);
   }*/
}

My main problem is the bottom part.

Thank you all very much !!

and fwd and bck are all undefined in you code.

What example are you working from?

Working step by step, have you been able to get a signal from the remote into some variable in your program, however?

a7

Since you have commented out all the servo handling code it’s not surprising if the servo isn’t doing anything. Are there any other problems?

Steve

Hi,
What Arduino controller are you using?
Have you been able to move your servo with the servo library example code?

Can you post a circuit diagram please?

Thanks… Tom… :grinning: :+1: :coffee: :australia:

Hi,
I think your;

//fwd 9
//bck 7

Should be

int fwd =  9;
int bck =  7;

Tom… :grinning: :+1: :coffee: :australia: