Arduino Servos Tutorial
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
Connect the servo red wire to 5V.
Connect the servo black wire to Gnd.
The Pin
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!
// 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);
}