Controlling Servo Motor Using IR Remote Control




About: Mechatronics engineer. I'm a Fab Lab Egypt team member.

If you are looking for comfort and controlling your electronic devices remotely, you will find your need in this instructable.

In this instructable we will learn how to control a servo motor with remote control, this will give you a general concept on how to control remotely. You should know that the remote control sends Infrared(IR) signals, so we will learn how to receive and read these signals using Arduino.

Step 1: Required Components

  • Arduino UNO
  • Servo motor
  • Remote control
  • IR receiver
  • Breadboard
  • Jumper wires

Step 2: Wiring

We use arduino UNO to control the servo motor to make the functionality we want.

We use IR receiver to read IR signals from remote control.

Wiring IR receiver and servo motor is shown in pictures.

Follow the steps of wiring in the pictures.

Step 3: The Programming

First, download IRremote library for arduino from this link.

Copy the library to Local Disk(C:) > Program Files(x86) > Arduino > libraries

Open IRremote demo example from Arduino IDE as picture 1 then upload to arduino board.

Then open serial monitor and try to click on any button of remote control to send a signal to IR receiver, the HEX code of each button must appear in serial monitor as picture 2

Then detect the HEX code of the buttons using to control the servo motor, assume you will use two buttons of your choice, one for clockwise rotation and another for counter clockwise rotation.

for example, use (+) for clockwise and (-) for counterclockwise, so you have to get their HEX codes.

(+) ---> A3C8EDDB

(-) ---> F076C13B

In the final code, the functionality is when clicking at any of two buttons the motor is toggling between the rotation in main direction and stop so when first click at any of two buttons the motor will rotate in button's direction, and when second click at same button the motor will stop as shown in the video.

The code is:

// Written by: Mohamed Soliman
// This code is for controlling servo motor with IR remote control // When clicking at any of two buttons the motor is toggling between the rotation and stop

#include <IRremote.h> //must copy IRremote library to arduino libraries #include <Servo.h> #define plus 0xA3C8EDDB //clockwise rotation button #define minus 0xF076C13B //counter clockwise rotation button

int RECV_PIN = 2; //IR receiver pin Servo servo; int val; //rotation angle bool cwRotation, ccwRotation; //the states of rotation

IRrecv irrecv(RECV_PIN);

decode_results results;

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

void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); // Receive the next value

if (results.value == plus) { cwRotation = !cwRotation; //toggle the rotation value ccwRotation = false; //no rotation in this direction }

if (results.value == minus) { ccwRotation = !ccwRotation; //toggle the rotation value cwRotation = false; //no rotation in this direction } } if (cwRotation && (val != 175)) { val++; //for colockwise button } if (ccwRotation && (val != 0)) { val--; //for counter colockwise button } servo.write(val); delay(20); //General speed }

Step 4: Let Your Circuit Working

Have fun with your remotely controlled servo motor.

With the same concept you can remotely control everything you need from a single LED to any device in your room.

2 People Made This Project!


  • PCB Contest

    PCB Contest
  • Make it Glow Contest 2018

    Make it Glow Contest 2018
  • Toys Contest

    Toys Contest

52 Discussions


3 years ago on Introduction

Very nice instructable mohamed ! :)
One doubt i have is, the servo runs continuously for as long as the button is pressed or what ?

2 replies

No, it runs continuously for first click and stops for second click.

that's because the remote doesn't send continuous signal for one click.

check that you copied IRremote library to arduino libraries, and try to remove RobotIRremote library which is mainly existed in arduino libraries so that the code work correctly.


Question 2 days ago

I want a code to control 2 servos with ir remote.please give me the code for that,your project was great and I was successful in controlling one servo


Question 8 months ago on Step 4

Hey this is brilliant. Only issue is I replace the existing hex codes with my hex codes but it then says that they aren't defined. I'm new to this stuff. Help would be greatly appreciated

1 more answer

Answer 2 days ago

Just put 0x in front of your hex code.

For example.....0xffe056


Question 4 days ago on Step 2

the wiring in your last picture is confusing from the diagram. ??


12 months ago

I've been repeating this over and over again but the codes are not showing in the serial monitor... What on earth did I miss ???

1 reply

Reply 3 months ago

1.único que tienes que cambiar es la sección de pin digital, ya que está en el numero 11 (creo que era ese), tu lo tienes que poner en el 9.


5 months ago

mohamed i love you thank u so much you absolutley made my day


Iam copied the ir remote library in the arduino library but I didnt see the irremote demo on the examples plz help me

Abhijith Assariparambil

Question 10 months ago on Introduction

I followed your instructions and downloaded the library and copy it in the arduino library but I didnt find irremote demo plz help me


11 months ago

where to put the remote code