IR Remote & Servo Motor

I would not power the servo through the Arduino...

I followed the steps on Circuito which has the same power supply I've got so I didn't think it would be a problem, plus it works fine using the 'sweep' example code.

How should the servo be powered?

I would wire in parallel and not go through the Arduino to power the Servo. Some servo draw lots of current and this could be too much for the the thin copper traces on the board.

Do you have an example of this please? It’s all new to me.

Also any idea how sweep works with no issues but I can’t get the servo to work with the IR remote?

which arduino do you have?
did you fix the double Servo library issue?

It’s the Uno rev 3 and yeah the issue is sorted.

can you clarify ? it seems that the servo is actually on pin 2 and some unnamed component on pin 3 in your image

On the physical setup, servo is pin 3 and IR receiver on 2.

so the image is correct then

So move servo to another pin. If I remember well, ir-remote occupy pwm on pins 3 and 11.

Indeed, the doc states it's using timer2, send on pin 3 and messes with PWM on pins 3 & 11

so move the servo to another pin.

Except that Servo.h does not utilize PWM, it uses timer2, with an interrupt process that can serve up to 12 servos, any output-capable pin. So, hmmm.

hum so timer2 conflict then because I think that's the one by default for IRRemote

What's going on with that linear voltage regulator?
You're inputting to the L7805 from Arduino VIN? Why?
Then that L7805 outputs to the breadboard power rail and that's your servo power?

As far as I can tell, you're robbing Peter to pay Paul.

Vin can be used as a source of the output voltage/current of the input. Not a big deal, for small currents. Feeding a 7805, and a servo from that, is original, and may well be a source of issues, but the OP has stated repeatedly that the example sweep.ino works just fine. This is pretty much a red herring, though it's certainly unusual.

The issue is the use of two different libraries that refuse to 'share' the timer they're constructed to use. Servo.h, AFAIK, has no ability to change timers. I'm not familiar with the IR library.
And by the way, this can be tested successfully on Wokwi, but fails on real hardware. One instance where I'm pretty disappointed in Wokwi.

That's to do with the IR library, the methods are deprecated if OP is using a 4.x library with code written for the 2.x library.
https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#converting-your-2x-program-to-the-4x-version
I mentioned this before.
@parryg101 what IRRemot library version you using?
You could always roll the library back instead of making the changes described in the link (should work).
@camsysca if you say it's ok to use the VIN that way, ok. I wouldn't but there's more than one way to skin a banana.
As for servos and IR library, yep, it works fine on Uno R3.
Here's old 2.x library based code (and a lotta copy and paste from Adafruit, thanks Adafruit!) that does exactly that.

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

#define PIXEL_PIN   4
#define PIXEL_COUNT 12
// MagiQuest protocol for IR
#define MAGIQUEST_PERIOD     1150
#define MAGIQUEST_SPACE_ZERO 850
#define MAGIQUEST_MARK_ONE   580
#define MAGIQUEST_SPACE_ONE  600
#define MAGIQUEST_BITS 56

#define MAGIQUEST 11

union magiquest {
  uint64_t llword;
  uint8_t    byte[8];
  uint32_t  lword[2];
  struct {
    uint16_t magnitude;
    uint32_t wand_id;
    uint8_t  padding;
    uint8_t  scrap;
  } cmd ;
} ;
#define ERR 0
#define DECODED 1

int recv_pin = A0;
IRrecv irrecv(recv_pin);

decode_results results;
magiquest data;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

unsigned long previousMillis;
unsigned long currentMillis = millis();
int ledState;

class Flasher
{
    int ledPin;
    long OnTime;
    long OffTime;
    int ledState;
    unsigned long previousMillis;

  public:
    Flasher(int pin, long on, long off)
    {
      ledPin = pin;
      pinMode(ledPin, OUTPUT);

      OnTime = on;
      OffTime = off;

      ledState = LOW;
      previousMillis = 0;
    }

    void Update()
    {
      unsigned long currentMillis = millis();
      if ((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
      {
        ledState = LOW;
        previousMillis = currentMillis;
        digitalWrite(ledPin, ledState);
      }
      else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
      {
        ledState = HIGH;
        previousMillis = currentMillis;
        digitalWrite(ledPin, ledState);
      }
    }
};

class Opener
{
    Servo servo;               // the servo
    int increment;             // increment to move for each interval
    int pos = 0;               // current servo position
    int  updateInterval;       // interval between updates
    unsigned long lastUpdate;  // last update of position

  public:
    Opener(int interval)
    {
      updateInterval = interval;
      /*(B): changing increment will change how many steps between its defined MixMax
        it will move at at time. Depending on how the servo is connected to the sensor,
        ie: distance from the servo horn, more or less may be needed.
      */
      increment = 1;
    }

    void Attach(int pin)
    {
      servo.attach(pin);
      servo.write(15);
    }

    void Detach(int pin)
    {
      servo.detach();
    }

    void servoSpeedControl()
    {
      delay(100); // good rate of opening and shutting lid, not too slow or fast
    }

    void oneWay() {
      if ((millis() - lastUpdate) > updateInterval) // time to update
      {
        lastUpdate = millis();
        for (pos = 15; pos <= 175; pos += 1)//default pos += 1
        {
          servo.write(pos);
          servoSpeedControl();
        }
      }
    }
    void theOtherWay() {
      if ((millis() - lastUpdate) > updateInterval)
        for (pos = 175; pos >= 15; pos -= 2)
        {
          servo.write(pos);
          servoSpeedControl();
        }
    }
    void Update() {
      Attach(11); // start sending servo pulses down signal wire to Arduino pin 11
      oneWay(); // open
      delay(10000); // hold
      theOtherWay(); // close
      Detach(11); // stop sending servo pulses to extend life of servo
    }
};

Flasher led1(9, 200, 400);
// (C): the rate at which the servo sweeps. Less is faster.
Opener opener1(10);

void setup() {
  Serial.begin(9600);
  Serial.println(F("halloweenTreatChest2022Final"));
  delay(1500);
  strip.begin();
  strip.show();
  strip.setBrightness(255);
  colorWipe(strip.Color(255, 0, 0), 25);
  irrecv.enableIRIn();
}

void loop() {
  led1.Update(); //get this up and running, waiting for our cue
  if (irrecv.decode(&results)) {

    decodeMagiQuest(&results, &data);

    //  Serial.print("wand_id: ");  // for debugging
    Serial.println(data.cmd.wand_id);

    if ((data.cmd.wand_id == 962781697) || (data.cmd.wand_id == 965771137) || (data.cmd.wand_id == 969260033) || (data.cmd.wand_id == 469759489)
        || (data.cmd.wand_id == 289273217) || (data.cmd.wand_id == 6064422497) || (data.cmd.wand_id == 470994049)) {
      theaterChase(strip.Color(7, 5, 70), 55); // Angler Abode
      //change the lock indicator to green
      colorWipe(strip.Color(0, 255, 0), 25);
      Opener1.Update();
      led1.Update();
      delay(1000);
      //and change the neoPixels back to red
      colorWipe(strip.Color(255, 0, 0), 25);
    }
    else if ((data.cmd.wand_id != 962781697) || (data.cmd.wand_id != 965771137) || (data.cmd.wand_id != 969260033)
             || (data.cmd.wand_id == 469759489) || (data.cmd.wand_id == 289273217) || (data.cmd.wand_id == 6064422497)) {
      delay(300);
      wrongWand();
    }
    irrecv.resume();
  }
}

int32_t  decodeMagiQuest(decode_results *results, magiquest *mdata) {
  magiquest data;
  data.llword = 0;

  int16_t offset = 1;
  uint16_t mark_;
  uint16_t space_;
  uint8_t multiple_;

  if (irparams.rawlen < 2 * MAGIQUEST_BITS) {
    return ERR;
  }
  while (offset + 1 < irparams.rawlen) {
    mark_ = results->rawbuf[offset];
    space_ = results->rawbuf[offset + 1];
    multiple_ = space_ / mark_;
    // it is either 25% + 75% or 50% + 50%

    if (MATCH_MARK(space_ + mark_, MAGIQUEST_PERIOD)) {
      if (multiple_ > 1) {
        data.llword <<= 1;
      } else {
        data.llword = (data.llword << 1) | 1;
      }
    } else {
      return ERR;
    }
    offset++;
    offset++;
  }
  // Success
  results->bits = (offset + 1) / 2;
  if (results->bits < 12) {
    results->bits = 0;
    return ERR;
  }
  //results->magiquestMagnitude = data.cmd.magnitude;
  results->value = data.cmd.wand_id;
  results->decode_type = MAGIQUEST;

  // fill in our magiquest struct
  mdata->cmd.magnitude = data.cmd.magnitude;
  mdata->cmd.wand_id = data.cmd.wand_id;
  return DECODED;
}

void wrongWand() {
  theaterChase(strip.Color(7, 5, 70), 55); // Angler Abode
  delay(2500);
  colorWipe(strip.Color(255, 0, 0), 25);
  strip.show();
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}


//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
    for (int q = 0; q < 3; q++) {
      for (int i = 0; i < strip.numPixels(); i = i + 3) {
        strip.setPixelColor(i + q, c);  //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (int i = 0; i < strip.numPixels(); i = i + 3) {
        strip.setPixelColor(i + q, 0);      //turn every third pixel off
      }
    }
  }
}

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

You can choose timer1 or 2 on ir-remote.
Servo.h library states " On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins."
But according to OP he doesn't use servo default pin 9, instead he uses 3. And only he knows what servo library he has installed....
And the sweeping servo code that works might have had different setup.
OP needs to provide consistent information to get his issue solved.

Quite a lot of replies here. I've moved the servo to PIN number 9 but still have the same outcome. What information is required here to get this one resolved?

I've copied my current code below. When I upload this to the board, the servo makes a 'clicking' sound and doesn't respond to the IR remote button press.

Here's the serial monitor on button press with the decode code if this helps.

Protocol=NEC Address=0x0 Command=0x45 Raw-Data=0xBA45FF00 32 bits LSB first
Send with: IrSender.sendNEC(0x0, 0x45, <numberOfRepeats>);
/* ============================================
  code is placed under the MIT license
  Copyright (c) 2024 J-M-L
  For the Arduino Forum : https://forum.arduino.cc/u/j-m-l

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
  ===============================================
*/

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

const byte IR_RECEIVE_PIN = 2;
const byte SERVO_PIN = 9;

Servo servo;

void doNothing() {}

void animation() {
  Serial.println(F("MOVING TO 100°"));
  servo.write(90);
  Serial.println(F("WAITING FOR 3s"));
  delay(3000);
  Serial.println(F("MOVING TO 0°"));
  servo.write(0);
  Serial.println(F("DONE"));
}

void handleCommand() {
  if (IrReceiver.decode()) {
    switch (IrReceiver.decodedIRData.command) {
      case 45:
        Serial.println("POWER ➜ ANIMATION");
        animation();
        break;

      default: break;
    }
    IrReceiver.resume();
  }
}

void setup() {
  Serial.begin(115200);
  servo.write(0);
  servo.attach(SERVO_PIN);
  IrReceiver.begin(IR_RECEIVE_PIN);
}

void loop() {
  handleCommand();
}

Do you see anything in the serial monitor ?

Can you unplug the power of the servo and see if the code runs as expected ?

Side note

This should read
#include <IRremote.hpp>
As in my example

If that does not compile, you don’t have the right version of the library installed.

Actual wiring, actual code and actual output are needed to debug a problem.
Then changing only one thing at a time can quickly lead to the root of your problem.
You had the new ir library code working already in your previous topic, why you switched to the old one? Also, is your servo.h the latest/default/only one servo library that you installed from library manager (I mean, not some old fork you found online).