Controlling Servo Motor With IR Remote Using Arduino

by RonFrtek in Circuits > Arduino

1473 Views, 2 Favorites, 0 Comments

Controlling Servo Motor With IR Remote Using Arduino

Controlling Servo Motor With IR Remote Using Arduino

In this tutorial we are going to learn how to control a Servo motor using IR remote and Arduino

Watch the Video!

What You Will Need

IR-Remote.png
oky3272-infrared-sensor-receiver.jpg
HTB1TMikbyjrK1RjSsplq6xHmVXa3.jpg
VisuinoAdvrtisemenESPNowESP32C3-1.jpg
FNLOD2CKEY93G5N.jpg
FMT2X9VKEY93G5P.jpg
  • IR Remote Sender
  • IR Receiver module
  • Servo Motor
  • Arduino UNO (or any other Arduino or ESP)
  • Jumper wires
  • Visuino program: Download Visuino


Brought by PCBWay

2022-08-26_13-41-18.jpg

Thank you PCBWay for supporting this tutorial and helping users learn more about electronics.

What I like about the PCBWay is that you can get 10 boards for approximately $5 which is really cost effective for professional made boards, not to mention how much time you save!

Go check them out here. They also offer a lot of other stuff in case you might need it like assembly3D printingCNC machining and a lot more.

The Circuit

2022-09-30_15-39-53.jpg
  • Connect Servo motor "Orange" (signal) pin to Arduino Digital pin[3]
  • Connect Servo motor "Red" pin to Arduino positive pin[5V]
  • Connect Servo motor "Brown" pin to Arduino negative pin[GND]
  • Connect IR RECEIVER pin (S) pin to Arduino Digital pin[2]
  • Connect IR RECEIVER pin [+] to Arduino positive pin[5V]
  • Connect IR RECEIVER pin [-] to Arduino negative pin[GND]



Start Visuino, and Select the Arduino UNO Board Type

FRWQB80K1RVKKV9.LARGE.jpg
Visuino-Select-Board-UNO.jpg

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add Components

2022-09-30_14-24-52.jpg
2022-09-30_14-28-16.jpg
2022-09-30_14-27-23.jpg
2022-09-30_14-26-25.jpg
  • Add "Infrared Remote Receiver" component
  • Add "Up/Down Counter" component
  • Add "Integer To Analog" component
  • Add "Servo" component

In Visuino Set Components

2022-09-30_14-29-39.jpg
2022-09-30_14-30-17.jpg
2022-09-30_14-30-31.jpg
2022-09-30_14-41-03.jpg
2022-09-30_14-41-24.jpg

Lets set the commands for the Left & Right button on the Remote, you will need a Code for that, in my case it was 16734885 & 16716015 each Remote might use different code, if you do not have it check out the Next step on how to obtain the code.

  • Double Click on the "InfraredReceiver1" and in the "Elements" window drag "Decode NEC Command" to the Left side and in the properties set Value to 16734885
  • Drag another "Decode NEC Command" to the Left side and in the properties set Value to 16716015
  • Close the "Elements" window


  • Select "UpDownCounter1" and in the properties window set:
  • Max > Value to 0
  • Max > Roll Over to False
  • Min> Value to 0
  • Min> Roll Over to False


  • Select "IntegerToAnalog1 " and in the properties window set "Scale" to 0.1



How to Obtain the Codes From a Remote Controller

2022-09-30_15-01-50.jpg
  • Connect "InfraredReceiver1" pin [Out] to Arduino Serial pin [0]
  • Upload the Arduino Code & open Serial tab, Click on the Left & Right button on the Remote and you should see the Codes

In Visuino Connect Components

2022-09-30_15-10-31.jpg
  • Connect Arduino Digital pin [2] to "InfraredReceiver1" pin [Sensor]
  • Connect "InfraredReceiver1" > "Decode NEC Command1" pin [Out] to "UpDownCounter1" pin [Up]
  • Connect "InfraredReceiver1" > "Decode NEC Command2" pin [Out] to "UpDownCounter1" pin [Down]
  • Connect "UpDownCounter1" pin [Out] to "IntegerToAnalog1" pin [In]
  • Connect "IntegerToAnalog1" pin [Out] to "Servo1" pin [In]
  • Connect "Servo1" pin [Out] to Arduino Digital pin [3]

Generate, Compile, and Upload the Arduino Code

Visuino-Compile-UNO.jpg

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play

If you power the Arduino module, and press a Left or Right button on the IR Remote the Servo will Turn Right or Left each time.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this tutorial, you can download it and open it in Visuino: https://www.visuino.eu

Downloads