0% found this document useful (0 votes)
6 views

Internet of Things

Uploaded by

Sakshi Ujjlayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Internet of Things

Uploaded by

Sakshi Ujjlayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

INTERNET OF THINGS

ASSIGNMENT – 2

Aim: Interfacing Servo Motor with the Arduino

Introduction:

A Servo Motor is a small device that has an output shaft. This shaft can be.
positioned to specific angular positions by sending the servo a coded signal.
As long as the coded signal exists on the input line, the servo will maintain
the angular position of the shaft. If the coded signal changes, the angular
position of the shaft changes. Servo motors have three terminals – power,
ground, and signal. The power wire is typically red, and should be connected
to the 5V pin on the Arduino.

Components Required:

Hardware Required
Component Name Quantity
Arduino UNO
Servo motor
USB Cable
Breadboard
Jumper wires
Procedure:

1. The servo motor has a female connector with three pins. The darkest or
even black one is usually the ground. Connect this to the Arduino GND.
2. Connect the power cable that in all standards should be red to 5V
on the Arduino.
3. Connect the remaining line on the servo connector to a digital pin on
the Arduino.
4. Upload the code
5. Observe the position of the shaft
Code
#include<Servo.h>
Servo myservo;
int pos=0;
void setup()
{
// put your setup code here, to run once:
myservo.attach(7);}
void loop() {
// put your main code here, to run repeatedly:
for(pos=0;pos<=180;pos++)
{
myservo.write(pos);
delay (15);
}
delay (1000);
for (pos=180; pos>=0;pos--)
{
delay (15);
}
delay(1000);
}

You might also like