Controlling Servo Motor With Ir Remote Using Arduino

About the project

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

Project info

Difficulty: Easy

Platforms: ArduinoVisuino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

SG90 Micro-servo motor SG90 Micro-servo motor x 1
Jumper wires (generic) Jumper wires (generic) x 1
Arduino UNO Arduino UNO x 1
Infrared Module (Generic) Infrared Module (Generic) x 1

Software apps and online services

Visuino Visuino
Arduino Web Editor Arduino Web Editor
Arduino IDE Arduino IDE

Story

Step 1: What You Will Need

1 / 6

  • IR Remote Sender
  • IR Receiver module
  • Servo Motor
  • Arduino UNO (or any other Arduino or ESP)
  • Jumper wires
  • Visuino program: Download Visuino

Step 2:Brought by PCBWay


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.


Step 3: The Circuit

  • 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]

Step 4: Start Visuino, and Select the Arduino UNO Board Type

1 / 2

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

Step 5: In Visuino Add Components

1 / 4

  • Add "Infrared Remote Receiver" component
  • Add "Up/Down Counter" component
  • Add "Integer To Analog" component
  • Add "Servo" component

Step 6: In Visuino Set Components

1 / 5

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

Step 7: How to Obtain the Codes From a Remote Controller

  • 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

Step 8: In Visuino Connect Components

  • 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]

Step 9: Generate, Compile, and Upload the Arduino Code

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.

Step 10: 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

CAD, enclosures and custom parts

Visuino File

Go to download

Code

Visuino File

Credits

Photo of Ron

Ron

Arduino Developer

   

Leave your feedback...