Set Micro Servo Position

How to set the initial position for a micro servo

Prepare your servos for use by setting the position of the shaft to 90 degrees, the midpoint of its 180 degree total travel

Micro Servo Tower Pro 9g
Click on image to watch video showing how the micro servo position is set.

To do this, upload the sketch below to an Arduino Uno.. Then attach the servo ground and power leads to Grnd and +5v on the Uno. The Uno can power a single servo such as the Tower Pro Micro Servo 9g  without damage. You may choose to power the servo by a separate 5 volt power supply.  Set this up on  a breadboard.

Be sure to have an arm on the servo shaft so that you can see the movement when you connect the control wire to the Uno.

Insert the control wire into pin 9.

The shaft will rotate to the 90 degree position. Reset the arm on the shaft to the 90 degree position.

The video under the image shows how this is done using a Tower Pro Micro Servo 9g (clone)

Sketch

You can change this sketch to set a different initial position.

#include <Servo.h> // compiler directive to get the servo library
 
Servo myservo;  // create a servo object
// from here on use the variable "myservo" to 
// access and control the servo object
void setup() // the setup function is run once at boot
{ 
  myservo.attach(9);  // attaches to the servo on pin 9
  myservo.write(90);  // set the servo shaft at 90 degrees
} 
 
// the loop function runs after setup until the board is powered off 
void loop() 
{ 
  // do nothing
}

There is more information on using micro servos on Arduino Projects 
This information is summarized from Turnout Control With Arduinos and Servos
Tell others about this information by using one of these services. Thank you for the support.
Scroll to top