Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
technoesolution
Published © CC BY-NC-SA

Interface Servomotor With Arduino Uno

In this tutorial we are going to interface Servomotor with Arduino Uno. Servomotor are very useful in robotics, Let's connect to Arduino.

BeginnerFull instructions provided30 minutes2,527
Interface Servomotor With Arduino Uno

Things used in this project

Hardware components

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

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram

Code

Arduino Code

C#
Simply Copy the following code & upload in your Arduino IDE software.
/* 
 *    Hello friend welcome to Techno-E-Solution.
 *    Here is a code for Interfacing Servomotor with Arduino 
*/
#include <Servo.h>

Servo myservo;  

int pos = 0;    // variable to store the servo position

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

technoesolution
23 projects • 15 followers
Youtuber | Electrical Engineer | Electronics Lover | Article Writer | Project Developer |
Contact

Comments

Please log in or sign up to comment.