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.

<p>Very nice instructable mohamed ! :) <br>One doubt i have is, the servo runs continuously for as long as the button is pressed or what ?</p>
<p>No, it runs continuously for first click and stops for second click.</p><p>that's because the remote doesn't send continuous signal for one click.</p>
<p>Can I make it run continuously while pushing the button?</p>
<p>nice .work ....but Is it possible to increase the speed of rotation</p>
<p>yes it's possible, by decreasing the delay time, it's the time of rotation of 1 degree.</p>
<p>Hello I want to control Servo motor using count from webpage?</p><p>How can i do that?</p>
<p>explain more !!!</p>
<p>I seem to be getting an error compiling message could yoou help?</p>
<p>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.</p>
<p>Well explained and very useful.</p>
Interesting and nice project but how to increase servo speed
<p>Great Project! Thank you very much Mohamed! Very detailed!</p>
something went wrong in my build I don't know why. The hex code doesn't appear in my serial monitor.
<p>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... :(</p>
<p>Never mind, I changed the breadboard and it's working fine now! Just FYI! Have a good one! :)</p>
<p>Thanks it works great!</p>
<p>ive been getting this error message</p><p>Arduino: 1.8.1 (Windows 10), Board: &quot;Arduino Duemilanove or Diecimila, ATmega328&quot;</p><p>Build options changed, rebuilding all</p><p>C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope</p><p> int RECV_PIN = TKD2; // the pin the IR receiver is connected to</p><p> ^</p><p>Multiple libraries were found for &quot;IRremote.h&quot;</p><p> Used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote</p><p> Not used: C:\Program Files (x86)\Arduino\libraries\Arduino-IRremote-master</p><p>exit status 1</p><p>Error compiling for board Arduino Duemilanove or Diecimila.</p><p>This report would have more information with</p><p>&quot;Show verbose output during compilation&quot;</p><p>option enabled in File -&gt; Preferences.</p>
<p>woow....l have been looking for this</p>
<p>Hey there Mohamed,</p><p>Cheers for the Instructable. Every thing works as it should and is exactly what I needed.</p><p>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 &quot;idling&quot; but after a while it slowly comes back.</p><p>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.</p><p>Any ideas on how to stop this occuring?</p><p>Thanks heaps for your help</p><p>Tai</p>
<p>How can i change the speed of the servo via the remote?<br><br>also how can i make it rotate the full 360 degrees?</p>
<p>what is the outside range?</p>
<p>what is the range outside in the sun?</p>
<p>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?</p>
<p>did you find an answer to this ?</p>
What if i want to make it rotate 90 degrees on the first click and back to 0 during the 2nd click?
<p>Hi, how do you remove RobotIRemote from arduino libraries? </p>
<p>When I looked through the examples I couldn't find the IRremote.</p>
<p>You Have to download IRremote separately. Read the coding part of the instructable to see how</p>
Hi , I Cant Understand The Programing Method , How To Download The IR remote Library ?
<p>I get this error message when I try to compile it :( :</p><p>can you help me please ? </p><p>Arduino : 1.6.7 (Windows 10), Carte : &quot;Arduino/Genuino Uno&quot;</p><p>C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope</p><p> int RECV_PIN = TKD2; // the pin the IR receiver is connected to</p><p> ^</p><p>exit status 1</p><p>Erreur lors de la compilation.</p><p> Ce rapport contiendrait plus d'informations si l'option</p><p> &quot;Montrer les informations de sortie pendant la compilation&quot;</p><p> &eacute;tait activ&eacute;e dans Fichier &gt; Pr&eacute;f&eacute;rences.</p>
<p>hello, I can't upload the library on to my arduino IDE can you help me please ? </p>
<p>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 &quot;tx&quot; 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</p>
<p>Thats work is good</p>
<p>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. </p>
<p>hi friends please i have a problem in &quot; IRrecv irrecv(RECV_PIN);&quot; </p><p>IRrecvDemo:13: error: 'IRrecv' does not name a type</p><p>IRrecvDemo:15: error: 'decode_results' does not name a type</p><p>IRrecvDemo.ino: In function 'void setup()':</p><p>IRrecvDemo:20: error: 'irrecv' was not declared in this scope</p><p>IRrecvDemo.ino: In function 'void loop()':</p><p>IRrecvDemo:24: error: 'irrecv' was not declared in this scope</p><p>i copied the library IRremote in the write place and i mover IRrobot ;</p><p>could someone help me !!</p><p>IRrecvDemo:24: error: 'results' was not declared in this scope</p>
<p>When I looked through the examples I couldn't find the IRremote.</p>
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
<p>don't use air conditioning remote control, it sends various signals by one click.</p><p>It's better to use TV remote control</p>
<p>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. </p>

About This Instructable




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