Servo

Servo © GPL3+

How to use a Servo.

  • 14,298 views
  • 14 comments
  • 44 respects

Components and supplies

arduino board (any)
×1
Servos (Tower Pro MG996R)
×1

Apps and online services

About this project

It's easy!  

The Circuit

Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board. Note that servos draw considerable power, so if you need to drive more than one or two, you'll probably need to power them from a separate supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together.

The Code

First include the servo library.

#include <Servo.h>

Then make a name for your servo like s1 for servo 1.

Servo s1;

Next, in the void setup, say what pin it goes to.

s1.attach(9);

Lastly, whenever you want you can tell the servo to go wherever you want it to from 0 to 180.

s1.write(90);

Code

servoArduino
#include <Servo.h>

Servo s1;

void setup (){
  s1.attach(9);
  s1.write(90);
}

void loop(){
  
}

Schematics

servo setup
Servob
servo schematic
Servo

Comments

Similar projects you might like

All About Servo Motors and Servo Motor Tester

Project tutorial by RoboCircuits

  • 2,635 views
  • 1 comment
  • 8 respects

MKR1000 Servo Control Panel

Project tutorial by Scott Beasley

  • 4,943 views
  • 3 comments
  • 19 respects

Build A Tripod Using Arduino and Servo Motors

Project tutorial by Team Greenterminal

  • 3,960 views
  • 0 comments
  • 7 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 92,745 views
  • 88 comments
  • 243 respects
Add projectSign up / Login