Interfacing Servo Motor with the Arduino
INSTRUCTIONS
Step-1(Info.)
1.)
Source
2.)
Target
Note:
Make Connections First, Then move to the code Compilation
Step-2 (Connections)
1.)Drag and drop BreadBoard,Arduino and all other Components first.
2.)Connect
Pin A
with
Pin 1
of breadboard..
3.)Connect
Pin V
with
Pin 2
of breadboard..
4.)Connect
Pin G
with
Pin 3
of breadboard..
5.)Connect
Pin 1
with
Pin 11
of Arduino..
6.)Connect
Pin 5
of Breadboard with
GND Pin
of Arduino..
7.)Connect
Pin 4
of Breadboard with
Pin (5V)
of Arduino..
8.)Click on
"CHECK"
button to check the connections.
Step-3 (Code Compilation)
1.) Set servoMotor._____ as
"attach"
2.) Set the angle to
"180"
.
4.) click on
"COMPILE"
button to run and compile the code.
Components
Servo Motor
Arduino
BreadBoard
2
3
4
1
5
Bread Board
Servo Motor
A
V
G
Arduino UNO
Code Compiler
#include <Servo.h>
Servo servoMotor;
void
setup() {
servoMotor.
(11);
}
void
loop() {
// Rotate the servo from 0 to 180 degrees
for
(
int
angle =
0
; angle <=
; angle++) {
servoMotor.
write
(angle);
delay
(15);
}
// Rotate the servo from 180 to 0 degrees
for
(
int
angle =
180
; angle >=
0
; angle--) {
servoMotor.
write
(angle);
delay
(15);
}
}
CHECK
RESET
COMPILE
PRINT
© 2024 | Virtual Labs, IIT Roorkee