#include <Servo.h>
#include <IRremote.hpp>
#define IR_RECEIVE_PIN 11

int selectedMotor=0;

int motorsLowerLimit=5;
int motorsUpperLimit=175;

int motorResolution=10;

const int numMotors=5;
Servo motors[numMotors];
int motorPins[]={3, 5, 6, 9, 10};
int motorPositions[]={90, 90, 90, 90, 90};

void setup()
{
  for(int i=0; i<numMotors; i++)
  {
    motors[i].attach(motorPins[i]);
    motors[i].write(motorPositions[i]);
  }

	Serial.begin(9600);
  Serial.print("Good morning");
	IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}

void loop()
{
  if(IrReceiver.decode())
  {
    decodeIRHex(IrReceiver.decodedIRData.decodedRawData); 
    IrReceiver.resume();
  }
}

void decodeIRHex(long hex)
{
    Serial.println(hex, HEX);
    switch(hex)
    {
      case 0xb847ff00:
      case 0xFD02FF00:
        moveMotor(selectedMotor, motorResolution);
        break;
      case 0xba45ff00:
      case 0x6798FF00:
        moveMotor(selectedMotor, -1*motorResolution);
        break;
      case 0xf30cff00:
      case 0xCF30FF00:
        selectedMotor=0;
        break;
      case 0xe718ff00:
      //case 0xE718FF00:
        selectedMotor=1;
        break;
      case 0xa15eff00:
      case 0x857AFF00:
        selectedMotor=2;
        break;
      case 0xf708ff00:
      case 0xEF10FF00:
        selectedMotor=3;
        break;
      case 0xe31cff00:
      case 0xC738FF00:
        selectedMotor=4;
        break;
    }
}

void moveMotor(int motorIndex, int motorChange)
{
  if(motorPositions[motorIndex] + motorChange < motorsLowerLimit)
  {
    motorPositions[motorIndex]=motorsLowerLimit;
  }
  else if(motorPositions[motorIndex] + motorChange > motorsUpperLimit)
  {
    motorPositions[motorIndex]=motorsUpperLimit;
  }
  else
  {
    motorPositions[motorIndex] += motorChange;
  }
  
  motors[motorIndex].write(motorPositions[motorIndex]);
}
$abcdeabcde151015202530354045505560fghijfghij