Arduino + servo simple setup

Using servo with arduino is pretty easy.

Here is my setup:
Arduino with servo

Servo has 3wires, vcc, gnd and control.
My servo colors were
+5V – red,
gnd – brown
control – orange.

Code for arduino (my control wire goes to pin12):

Servo myServo;

int servoPin = 12;

void setup() {

void loop() {

#include – we load servo library
Servo myServo; – create an servo object
With int servoPin we just make simple variable to be more readable in code (currently doesn’t make sense as there is only one pin in use, but it’s a good habit to have).
myServo.attach(servoPin); – point to servo object to use “servoPin” pin.
myServo.write() function takes degrees as parameters.
My current servo takes from 0 to 180.

And video:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.