Servo

Liam Brady and Ryan Ferguson

Servos are specialized motors that support precise control. Rather than spinning off to oblivion like a motor, servos let the designer specify exactly where they want the object to rotate to. Most common servos allow for 180ยบ of rotation.

#include <Servo.h>
Servo myservo;

void setup() {
  myservo.attach(9);
}

void loop() {
  int val = analogRead(A0);
  val = map(val, 0, 1023, 0, 179);

  myservo.write(val);

  delay(15);
}