Sunday, February 15, 2015

Micro Servo Motor - calibrating position angles

I want to use a rather typical micro servo motor to move the eyes of my rover to "look" side to side and determine if there is an object present. I received the 3D prints this week for the servo mounting and the ultrasonic distance sensor so it's time to make sure my micro servo control works as planned. I'm going to use a Arduino Micro and some simple code with a basic bread board to bring the servo to life and tweak the positioning.
Parts Needed: 
1 Breadboard
1 Arduino Micro (or other Arduino board) ($24.95)
3 wires (female to female)
1 Micro Servo Motor  ($12.99)
1 USB to Micro USB cable ($9.99)  you might already have one from your smart phone


There are only three wires to connect so the hook up is easy... 
Here is the pin mapping:

Micro Pin    Servo Connection
Grd         --> Brown Wire
5V          --> Red Wire
 9            --> Yellow Wire

Insert the Arduino Micro into the breadboard and connect the ground, 5 volt and pin 9 to the servo motor as shown above. 

Upload the code to and and tweak the servo position values until they match your setup.. Get the code here.. MicroServoCalibration Code