2 Servos Controlled by IR Remote

Okay,

So I have scoured the internet for just about every servo w/ IR Remote codes
and tried to adapt them to my purpose.

I can do all the basic time delayed servo.write(x) and all that stuff.

My goal seems simple but to a layman who has only taken one course in Java it is proving to be a nightmare.

These two servos control the rotation of two wings mounted on a cosplayer's back.
The only function I really need are the two servos to toggle from spread wide open to straight back (to get through doorways). Being able to control by a few degrees per button press is NOT necessary, but at the very least I just want two positions to toggle between.

I found one code that I tried to test out and modify to no avail,

#include <IRremote.h>
#include <Servo.h> 

const byte RECV_PIN = 8;

IRrecv irrecv(RECV_PIN);
Servo myservo; 

byte position = 90; // range 0-180
boolean newIRdata = false;
unsigned long IRinput;

decode_results results;

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results))
  {
    IRinput = results.value;
    irrecv.resume(); // Receive the next value
    newIRdata = true;
  }
  if(newIRdata == true)
  {
   Serial.println(IRinput, HEX);
      switch(IRinput)
    {
     // move right 1 degree per button push
     case(0x4eb338c7): // right arrow
     position--;
     Serial.println(position);
     break;
     // move left 1 degree per button push
     case(0x4EB312ED): // left arrow
     position++;
     Serial.println(position);
     break;
     // go to 160
     case(0x4EB322DD): // up arrow
     position = 160;
     Serial.println(position);
     break;
     // go to 70
     case(0x4EB3B847): // down arrow
     position = 75;
     Serial.println(position);
     break;     
    }
     IRinput = 0;
     newIRdata = false;   
  }
  myservo.write(position);
}

Here is another code example that I tried to adapt by replacing PINS and IR CODES with no luck as well,

/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
 * Version 1.0  April 2013 by Chris Young http://cyborg5.com
 * "IR_Servo" Control a servo using an IR remote
 */
#include <IRLib.h>
#include <Servo.h> 
// You will have to set these values depending on the protocol
// and remote codes that you are using. These are from my Sony DVD/VCR
#define MY_PROTOCOL SONY
#define RIGHT_ARROW   0x86bca //Move several clockwise
#define LEFT_ARROW    0x46bca //Move servo counterclockwise
#define SELECT_BUTTON 0xd0bca //Center the servo
#define UP_ARROW      0x42bca //Increased number of degrees servo moves
#define DOWN_ARROW    0xc2bca //Decrease number of degrees servo moves
#define BUTTON_0 0x90bca  //Pushing buttons 0-9 moves to fix positions
#define BUTTON_1 0x00bca  // each 20 degrees greater
#define BUTTON_2 0x80bca
#define BUTTON_3 0x40bca
#define BUTTON_4 0xc0bca
#define BUTTON_5 0x20bca
#define BUTTON_6 0xa0bca
#define BUTTON_7 0x60bca
#define BUTTON_8 0xe0bca
#define BUTTON_9 0x10bca
IRrecv My_Receiver(11);//Receive on pin 11
IRdecode My_Decoder; 
Servo My_Servo;  // create servo object to control a servo 
int pos;         // variable to store the servo position 
int Speed;       // Number of degrees to move each time a left/right button is pressed
 
void setup() 
{ 
  My_Servo.attach(9);  // attaches the servo on pin 9 to the servo object 
  pos = 90;            // start at midpoint 90 degrees
  Speed = 3;           //servo moves 3 degrees each time left/right is pushed
  My_Servo.write(pos); // Set initial position
  My_Receiver.enableIRIn(); // Start the receiver
} 
 
void loop() 
{ 
    if (My_Receiver.GetResults(&My_Decoder)) {
       My_Decoder.decode();
       if(My_Decoder.decode_type==MY_PROTOCOL) {
          switch(My_Decoder.value) {
            case LEFT_ARROW:    pos=min(180,pos+Speed); break;
            case RIGHT_ARROW:   pos=max(0,pos-Speed); break;
            case SELECT_BUTTON: pos=90; break;
            case UP_ARROW:      Speed=min(10, Speed+1); break;
            case DOWN_ARROW:    Speed=max(1, Speed-1); break;
            case BUTTON_0:      pos=0*20; break;
            case BUTTON_1:      pos=1*20; break;
            case BUTTON_2:      pos=2*20; break;
            case BUTTON_3:      pos=3*20; break;
            case BUTTON_4:      pos=4*20; break;
            case BUTTON_5:      pos=5*20; break;
            case BUTTON_6:      pos=6*20; break;
            case BUTTON_7:      pos=7*20; break;
            case BUTTON_8:      pos=8*20; break;
            case BUTTON_9:      pos=9*20; break;
          }
        My_Servo.write(pos); // tell servo to go to position in variable 'pos' 
       }
     My_Receiver.resume();
    }
}

When I replace my appropriate PINs and remote key codes my servos do activate and do their idle jitter, however my remote does nothing. I can run serial monitor and receive codes no problem.

Even if someone can help me with just ONE servo toggling back and forth between two positions with the remote, I can figure out how to add the second.

crimson66:
When I replace my appropriate PINs and remote key codes my servos do activate and do their idle jitter, however my remote does nothing. I can run serial monitor and receive codes no problem.

Are the pins you are using different from the pins used in the code you provided above?
Are you using an Arduino UNO?
Are you saying that the Serial Monitor shows the IR codes you are using but the servo is not moving as expected?
Jitter on your servos could mean that the ground wire is not connected to Arduino Ground or maybe the power is inadequate. How are you powering the servo? The +5V line of an Arduino UNO is usually not adequate to power a servo. Allow about 1000 mA per servo.