Hello Friends! Welcome back to 'INNOVATIVE SCIENTIFIC INVENTIONS'. Today I will show you. How to Run Micro Servo Motor with Arduino UNO.
Circuit Diagram:
Code:
#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:
- Arduino UNO
- Micro Servo Motor
- Jumping Wires
How to Upload Code in Arduino:
- Open Arduino IDE.
- Paste the code in Arduino IDE.
- Compile the Code.
- Upload the Code in Board.
How to Select Board:
- Open Arduino IDE
- Click on 'Tools' Option
- Click on 'Board'
- Select your Board
How to Select Port:
- Open Arduino IDE
- Click on 'Tools' Option
- Click on 'Port'
- Select your Port
How to Save Sketch in Computer:
- Open Arduino IDE
- Click on 'File' Option
- Click on 'Save' Option
- Select your Folder
How to 'Save as' Sketch:
- Open Arduino IDE
- Click on 'File' Option
- Click on 'Save as' Option
- Select your Folder
IF YOU WANT TO DONATE FOR "INNOVATIVE SCIENTIFIC INVENTIONS" SO PLEASE CONTACT ME.
Video Link: https://youtu.be/MBp04Alq-Gg
0 Comments