hockey1alex
Published

Servo sweep

Check out my youtube channel (link in my profile) to see how I made it and other cool projects.

BeginnerFull instructions provided5,273
Servo sweep

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Male/Male Jumper Wires
×1
Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino Web Editor
Arduino Web Editor

Story

Read more

Schematics

Diragram

connect the pins as shown yellow to negative 9 black to ground red to 5 volts

Code

CODE

Java
just copie the code into web editor and upload it.
#include <Servo.h>

Servo myservo;  
int pos = 0;   
void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}/*

*/

Credits

hockey1alex
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.