click here to enter

Servo Motor

Kingston hackSpace

Servo Motor

<p">In hackSpace we have two types of servomotors; ones that can rotate to 180 degrees and ones that can rotate to 360 degrees, however they work on a same principles. They rotate fully forward or backwards instead of moving to a position. They are very similar to stepper motors, but they are less accurate (very good for prototyping). You can use any servo code, hardware or library to control these servos. Good for making simple moving robots. Comes with four different horns, as shown. They may require some simple calibration, simply tell the servo to ‘stop’ and then gently adjust the potentiometer in the recessed hole with a small screwdriver until the servo stops moving. 

 

Servo Motor

Arduino Pins

OUT

PIN D9

VCC

5V

GND

GND

To control with an Arduino, you have positive and negative to 5V and GND, and I would suggest connecting the control wire to pin 9 or 10 and using the Servo library included with the Arduino IDE (see below for an example sketch). 


#include  // I2C Arduino Library included 

Servo myservo;  // Create servo object to control a servo
// Twelve servo objects can be created on most boards

int pos = 0; // Variable to store the servo position

void setup() {
  myservo.attach(9);  // Attaches the servo on digital PWM Pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { 
    // Goes from 0 degrees to 180 degrees, in steps of 1 degree
    myservo.write(pos); // Tell servo to go to position in variable ‘pos’
    delay(15); // Waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // Goes from 180 degrees to 0 degrees
    myservo.write(pos); // Tell servo to go to position in variable ‘pos’
    delay(15); // Waits 15ms for the servo to reach the position
  }
}