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
Servo Motor
IR Sensor
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 Servo Motor. Thus, we can easily control the Motor.