Control servo motor

The servo motor can be controlled by using the servo library(Servo.h) in Arduino IDE. Plug in the control wire of the servo motor into one of the PWM pins. Attach the servo object to that pin.

  1. Servo servoMotor;
  2. servoMotor.attach(9);

To rotate the servo motor pass in a number between 0 and 180. The servo motor can only move up to 180 degrees.

  1. myservo.write(90);
  2. delay(2000);
  3. myservo.write(180);
  4. delay(2000);

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>