Controlling Servo Motor By Using IR Remote

Introduction

In this article, I am going to explain about the Controlling Servo motor, using IR Remote. If the motor can be used to run, they can be controlled by IR Remote in the use of OFF/ON.

Parts Of List

  • Arduino Uno
  • IR Remote
  • IR Remote Sensor
  • Bread Board
  • Hook Up Wires
  • Servo Motor

Servo Motor

  • Connect the VCC of the Servo Motor to the 5v of the Arduino Uno.
  • Connect the GND of the bluetooth to the Gnd of the Arduino Uno.
  • Connect the VIN of the bluetooth to the 09 of the Arduino Uno.

IR Sensor

  • Connect the IR Sensor to the Arduino board VIN -3pin.
  • Connect the IR Sensor to the Arduino board GND - Gnd.
  • Connect the IR Sensor to the Arduino board VCC - 5v.

Programming

  1. #include < IRremote.h > //must copy IRremote library to arduino libraries   
  2. #include < Servo.h > #define plus 0xA3C8EDDB //clockwise rotation button  
  3. # define minus 0xF076C13B //counter clockwise rotation button   
  4.  int RECV_PIN = 2; //IR receiver pin   
  5.  Servo servo;  
  6.  int val; //rotation angle   
  7.  bool cwRotation, ccwRotation; //the states of rotation   
  8.  IRrecv irrecv(RECV_PIN);  
  9.  decode_results results;  
  10.  void setup() {  
  11.      Serial.begin(9600);  
  12.      irrecv.enableIRIn(); // Start the receiver   
  13.      servo.attach(9); //servo pin   
  14.  }  
  15.  void loop() {  
  16.      if (irrecv.decode( & results)) {  
  17.          Serial.println(results.value, HEX);  
  18.          irrecv.resume(); // Receive the next value   
  19.          if (results.value == plus) {  
  20.              cwRotation = !cwRotation; //toggle the rotation value   
  21.              ccwRotation = false//no rotation in this direction   
  22.          }  
  23.          if (results.value == minus) {  
  24.              ccwRotation = !ccwRotation; //toggle the rotation value   
  25.              cwRotation = false//no rotation in this direction   
  26.          }  
  27.      }  
  28.      if (cwRotation && (val != 175)) {  
  29.          val++; //for colockwise button   
  30.      }  
  31.      if (ccwRotation && (val != 0)) {  
  32.          val--; //for counter colockwise button   
  33.      }  
  34.      servo.write(val);  
  35.      delay(20); //General speed   
  36.  }  
Explanation

In this blog, I told about controlling the Servo Motor, using the IR Remote Sensor and the IR Remote control. It is used for the farmer also in real time projects. IR Remote will be fixed in the Servor Motor. Thus, we can easily control the Motor. 
Ebook Download
View all
Learn
View all