abhiramarduino
Published

ARDUINO beginner's Project | Servo

Here you can learn how to control servo with ARDUINO.

BeginnerFull instructions provided1,595
ARDUINO beginner's Project | Servo

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Jumper wires (generic)
Jumper wires (generic)
×3

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Servo

Code

Servo

C/C++
#include <Servo.h>

Servo myservo; 

int pos = 0;   

void setup() {
  myservo.attach(9); //pin ~9
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { 
    myservo.write(pos);              
    delay(15);                      
  }
  for (pos = 180; pos >= 0; pos -= 1) {
    myservo.write(pos);              
    delay(15);                     
  }
}

Credits

abhiramarduino
0 projects • 2 followers

Comments