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
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 Sender
- IR Receiver module
- Servo Motor
- Arduino UNO (or any other Arduino or ESP)
- Jumper wires
- Visuino program: Download Visuino
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 assembly, 3D printing, CNC machining and a lot more.
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]
Start Visuino, and Select the Arduino UNO Board Type
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
- Add "Infrared Remote Receiver" component
- Add "Up/Down Counter" component
- Add "Integer To Analog" component
- Add "Servo" component
In Visuino Set Components
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
- 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
- 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
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