Arduino – find that stalling position of a servo

Posted: July 31, 2012 in Arduino

Below is the code for finding the stalling point of a servo. All seem to be different, even though I bought a batch of all the same servos the stalling positions are different. ie one is 93 and another is 91.

not the best video in the world, but you can see and hear the motor slow down then stop at value 93

 

// Includes
#include <Servo.h>

// Define global constants
#define lServoPin 9   // Left motor pin; This is a special PWN pin

// Define global servos
Servo LeftServo;

// Initialization function
void setup()
{
// Initialize server connections
LeftServo.attach(lServoPin);

// Initialize serial communications
Serial.begin(9600);
}

// Main loop
void loop()
{
// Set both servo at same speeds (Go straight)
for(int i = 0; i <= 180; i++)
{
LeftServo.write(i);
Serial.print(“Value: “);
Serial.print(i, DEC);
Serial.print(“\n”);
delay(500);
}
}

Leave a comment