Introduction: Controlling Servo Motor Using IR Remote Control

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.


akshay.d21 made it!(author)2015-08-25

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

mohamed+soliman made it!(author)2015-08-26

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.

giantpair made it!(author)2015-12-24

Can I make it run continuously while pushing the button?

elhadi30 made it!(author)2015-08-27

nice .work ....but Is it possible to increase the speed of rotation

mohamed+soliman made it!(author)2015-08-27

yes it's possible, by decreasing the delay time, it's the time of rotation of 1 degree.

nilesh2690 made it!(author)2015-08-27

Hello I want to control Servo motor using count from webpage?

How can i do that?

mohamed+soliman made it!(author)2015-08-27

explain more !!!

electronics+for+everyone made it!(author)2015-08-26

I seem to be getting an error compiling message could yoou help?

mohamed+soliman made it!(author)2015-08-26

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.

tmoir made it!(author)2015-08-25

Well explained and very useful.

GabrielL150 made it!(author)2017-07-11

I have been looking for this for some time, it's a great project.

It may be important to remember that some people probably have to delete the IR Remote Robot Library before adding the IR Remote library.

Thank you very much for sharing.

LIGHTING+ONF made it!(author)2017-05-15

Interesting and nice project but how to increase servo speed

alanflores7 made it!(author)2017-04-16

Great Project! Thank you very much Mohamed! Very detailed!

RF Controlled Servo.jpg
WarenGonzaga made it!(author)2017-02-16

something went wrong in my build I don't know why. The hex code doesn't appear in my serial monitor.

alanflores7 made it!(author)2017-04-16

I'm having the same issue WarenGonzaga! Did anybody replied to this issue? Any good troubleshooting ideas? I'm thinking my IR Receiver might be defective... :(

alanflores7 made it!(author)2017-04-16

Never mind, I changed the breadboard and it's working fine now! Just FYI! Have a good one! :)

TheRandomizedvidsG made it!(author)2017-03-28

Thanks it works great!

bobmaley123 made it!(author)2017-01-16

ive been getting this error message

Arduino: 1.8.1 (Windows 10), Board: "Arduino Duemilanove or Diecimila, ATmega328"

Build options changed, rebuilding all

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope

int RECV_PIN = TKD2; // the pin the IR receiver is connected to


Multiple libraries were found for "IRremote.h"

Used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote

Not used: C:\Program Files (x86)\Arduino\libraries\Arduino-IRremote-master

exit status 1

Error compiling for board Arduino Duemilanove or Diecimila.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

JeremiahM42 made it!(author)2016-12-18

woow....l have been looking for this

peadubs made it!(author)2016-12-15

Hey there Mohamed,

Cheers for the Instructable. Every thing works as it should and is exactly what I needed.

I do have one small issue though. When the motor is stationary with no input from the IR its seems like it is idling (almost sounds like a car idling at the traffic lights. If I put the motor under some load this removes the "idling" but after a while it slowly comes back.

Its almost like its getting too much constant power supply that is building up? Im not sure really. Im a real noob to electronics and Arduino (as in ive been reading about it maybe for a month now) so not really sure where to start.

Any ideas on how to stop this occuring?

Thanks heaps for your help


Hamham1234 made it!(author)2016-12-09

How can i change the speed of the servo via the remote?

also how can i make it rotate the full 360 degrees?

spenproject made it!(author)2016-11-20

what is the outside range?

spenproject made it!(author)2016-11-20

what is the range outside in the sun?

TianxiZ1 made it!(author)2016-09-10

Can this method work with a recreational vehicule's remote control? And is it possible to connect 2 servos on different ports instead of 1? If so, how can it be done?

wampablo made it!(author)2016-11-12

did you find an answer to this ?

AnnTech made it!(author)2016-10-21

What if i want to make it rotate 90 degrees on the first click and back to 0 during the 2nd click?

JustARobotDude made it!(author)2016-10-19

Hi, how do you remove RobotIRemote from arduino libraries?

ben2rouse made it!(author)2015-10-06

When I looked through the examples I couldn't find the IRremote.

JustARobotDude made it!(author)2016-10-19

You Have to download IRremote separately. Read the coding part of the instructable to see how

Kettevan04 made it!(author)2016-07-29

Hi , I Cant Understand The Programing Method , How To Download The IR remote Library ?

LucasF65 made it!(author)2016-07-06


MarineM1 made it!(author)2016-05-08

I get this error message when I try to compile it :( :

can you help me please ?

Arduino : 1.6.7 (Windows 10), Carte : "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope

int RECV_PIN = TKD2; // the pin the IR receiver is connected to


exit status 1

Erreur lors de la compilation.

Ce rapport contiendrait plus d'informations si l'option

"Montrer les informations de sortie pendant la compilation"

était activée dans Fichier > Préférences.

MarineM1 made it!(author)2016-05-04

hello, I can't upload the library on to my arduino IDE can you help me please ?

simonlote98 made it!(author)2016-05-01

i did it ! but it doesnt work without the computer, i mean, using a power supply, the arduino cant receive any signal, i know this because when i use the computer, i press any button and the "tx" led of arduino blink one time, and the led assigned turns on correctly but when i use a external power supply, nothing happens, please help me :p

laith+mohamed made it!(author)2015-12-03

Thats work is good

LeonS19 made it!(author)2015-11-14

I follow your programming code, use it in robotic arm grabbing and releasing. So far, there is one problem I encounter, when i press plus (use for grabbing), the servo works fine but when i press minus to return the servo back into original position (for releasing). it wont happen unless i press the ir control many time. I tried changing different button, delay time....but in vain. Anyone can help? Urgent.

khalilos made it!(author)2015-11-07

hi friends please i have a problem in " IRrecv irrecv(RECV_PIN);"

IRrecvDemo:13: error: 'IRrecv' does not name a type

IRrecvDemo:15: error: 'decode_results' does not name a type

IRrecvDemo.ino: In function 'void setup()':

IRrecvDemo:20: error: 'irrecv' was not declared in this scope

IRrecvDemo.ino: In function 'void loop()':

IRrecvDemo:24: error: 'irrecv' was not declared in this scope

i copied the library IRremote in the write place and i mover IRrobot ;

could someone help me !!

IRrecvDemo:24: error: 'results' was not declared in this scope

ben2rouse made it!(author)2015-10-06

When I looked through the examples I couldn't find the IRremote.

dtare made it!(author)2015-09-27

hey i uploaded the code and all and it works..but when i receive the signal i get various other signals rather than the button i pressed..and TX continiously beeps even if i havent pressed any button ...please help

mohamed+soliman made it!(author)2015-09-27

don't use air conditioning remote control, it sends various signals by one click.

It's better to use TV remote control

Volthaus+Electronics+Laboratory made it!(author)2015-09-07

I am going to give your Instructable a try. I built an amplifier for the sound signal from my Roku. I am putting the amp into an empty computer power supply case and will try to turn the volume pot with the servo. I have almos the same remote you are using and have already deciphered its codes. Plus i want to be able to use it to turn on and off the amp. I think some kind of simple latching circuit should work there. Thanks for taking the time to post this.

About This Instructable




Bio: Mechatronics engineer. I'm a Fab Lab Egypt team member.
More by mohamed soliman:Control servo motor using 1SheeldControlling servo motor using IR remote controlDIY Robotic Arm
Add instructable to: