Arduino Servos Tutorial

by knexguy51 in Circuits > Arduino

277 Views, 1 Favorites, 0 Comments

Arduino Servos Tutorial

servo.png

I will walk you through the process of spinning a Arduino servo motor.

Supplies

1 Arduino board

1 Arduino SG90 Servo

Gnd and 5V Wires

ground%V.png

Connect the servo red wire to 5V.

Connect the servo black wire to Gnd.

The Pin

servo.png

Attach the other wire to a pin of your choice... As long as you change it in the code.

Remember to Code Every Single Time!

download (1).jpg

// Include the Servo library

#include

// Declare the Servo pin

int servoPin = 7;

// Create a servo object

Servo Servo1;

void setup() {

// We need to attach the servo to the used pin number

Servo1.attach(servoPin);

}

void loop(){

// Make servo go to 0 degrees

Servo1.write(0);

delay(1000); // Make servo go to 90 degrees

Servo1.write(90); delay(1000); // Make servo go to 180 degrees

Servo1.write(180); delay(1000);

}