How to Run Servo Motor with Arduino Nano | Run Servo Motor | InnoScienIn9 |


Hello Friends! Welcome back to 'INNOVATIVE SCIENTIFIC INVENTIONS'. Today I will show you. How to Run Servo Motor with Arduino Nano.



Circuit Diagram:


Code:


  //Code

/* Sweep
 by BARRAGAN <http://barraganstudio.com>
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

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
  }

}





What do you need to Create this Project:


  1. Arduino Nano
  2. Micro Servo Motor
  3. Jumping Wires


How to Upload Code in Arduino:
  1. Open Arduino IDE.
  2. Paste the code in Arduino IDE.
  3. Compile the Code.
  4. Upload the Code on Board.


How to Select Board:
  1. Open Arduino IDE
  2. Click on 'Tools' Option
  3. Click on 'Board'
  4. Select your Board


How to Select Port:
  1. Open Arduino IDE
  2. Click on 'Tools' Option
  3. Click on 'Port'
  4. Select your Port

How to Save Sketch in Computer:
  1. Open Arduino IDE
  2. Click on 'File' Option
  3. Click on 'Save' Option
  4. Select your Folder

How to 'Save as' Sketch:
  1. Open Arduino IDE
  2. Click on 'File' Option
  3. Click on 'Save as' Option
  4. Select your Folder

IF YOU WANT TO DONATE FOR "INNOVATIVE SCIENTIFIC INVENTIONS" SO PLEASE CONTACT ME.

WHATSAPP: +923110084691

EASY PAISA: +923327810553




              Click Here to Download Arduino IDE 
Arduino IDE Download Link:

Post a Comment

1 Comments

  1. not very innovative....copying the sweep code that's provided in the arduino IDE and pasting it here as it you wrote it!

    ReplyDelete