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

Experiment 9 - Servo Motor

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

Experiment 9 - Servo Motor

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

Experiment No 9 Student ID

Date Student Name


Servo motor (SG-90) control using Arduino Genuino UNO

Aim/Objective: The main objective of this experiment is to interface Servo motor (SG-90)
Arduino Genuino UNO and control it’s position.

Components required:

Software Hardware
Arduino UNO Board
Tinkercad Arduino UNO Cable
Arduino IDE (To be installed in Laptop) Servo Motor
Potentiometer
Jumper wires
Pre-Requisites:

 Basics of Arduino Uno


 Basics of Servo motor
Pre-Lab:

1. What is a servo motor?


A servo motor is a type of motor that is designed for precise control of angular position.
It consists of a small DC motor, a set of gears, and a control circuit that provides
feedback to accurately position the motor shaft.
2. How is the SG-90 servo motor connected to the Arduino Genuino UNO?
The SG-90 servo motor is connected to the Arduino Genuino UNO using three wires.
The red wire is connected to the 5V pin of the Arduino for power, the brown or black
wire is connected to the GND pin for ground, and the orange or yellow wire is
connected to a digital pin (e.g., pin 9) for control.
3. How does the Arduino Genuino UNO control the position of the servo motor?
The Arduino Genuino UNO controls the position of the servo motor by sending a PWM
(Pulse Width Modulation) signal to the control wire of the servo motor. The duration
of the pulse determines the position of the motor shaft, with different pulse durations
corresponding to different angles.
4. What is the range of motion for the SG-90 servo motor?
The SG-90 servo motor has a range of motion of approximately 180 degrees. This
means it can rotate from 0 degrees to 180 degrees, allowing for a wide range of
positioning options.
5. How can we control the speed of the servo motor using the Arduino Genuino?
The speed of the servo motor is controlled by the duration of the pulse sent by the
Arduino Genuino UNO. By adjusting the pulse duration, we can control the speed at
which the servo motor moves. Shorter pulse durations result in faster movement, while
longer pulse durations result in slower movement.
In-Lab:

Program:

#include <Servo.h>
Servo myservo;
void setup()
{
myservo.attach(9);
Serial.begin(9600);
}
void loop()
{
int pos;

for (pos = 0; pos <= 180; pos += 1)


{
myservo.write(pos);
Serial.print("The Current Position is ");
Serial.print(pos);
Serial.println(" Degrees");
delay(500);
}
for (pos = 180; pos >= 0; pos -= 1)
{
myservo.write(pos);
Serial.print("The Current Position is ");
Serial.print(pos);
Serial.println(" Degrees");
delay(500);
}
}
Connection Diagram:
Procedure:
 Give the connections to the Arduino board as shown in the connection diagram.
 Open Arduino IDE in the computer
 Create new file File_--→ New
 Type your program and Save it in appropriate location in your computer.
 Compile your program by clicking Verify option in the menu.
 Once the program compiled successfully, connect the Arduino board to the computer
using USB cable.
 After connecting, go to Tools ----→Board ---→ Select Arduino/Genuino Uno option
 After selecting board, go to Tools ----→Port ---→ Select Arduino Uno COM port 3
(name may appear differently for other computers).
**Note that this port option will be displayed only when board is connected to computer
 Now upload the program to the Arduino board by clicking Upload option.
 Observe the output.

Circuit/Schematic Diagram:
Results:

Analysis and Inferences:

VIVA-VOCE Questions (In-Lab):

1. What is a servo motor?

A servo motor is a type of motor that is designed for precise control of angular position.
It consists of a small DC motor, a set of gears, and a control circuit that provides
feedback to accurately position the motor shaft.

2. How does a servo motor work?

A servo motor works by receiving control signals in the form of pulses. The duration
of the pulse determines the desired position of the motor shaft. The control circuit inside
the servo motor compares the received pulse duration with the current position of the
motor shaft and adjusts the motor's rotation to reach the desired position.

3. How is the SG-90 servo motor connected to the Arduino Genuino UNO?

The SG-90 servo motor is connected to the Arduino Genuino UNO using three wires.
The red wire is connected to the 5V pin of the Arduino for power, the brown or black
wire is connected to the GND pin for ground, and the orange or yellow wire is
connected to a digital pin (e.g., pin 9) for control.

4. How can we control the position of the servo motor using the Arduino Genuino
UNO?

We can control the position of the servo motor using the Arduino Genuino UNO by
sending PWM (Pulse Width Modulation) signals to the control wire of the servo motor.
By varying the duration of the pulse, we can set the desired angle of the servo motor
shaft.

5. What is the range of motion for the SG-90 servo motor?

The SG-90 servo motor has a range of motion of approximately 180 degrees. This
means it can rotate from 0 degrees to 180 degrees, allowing for a wide range of
positioning options.
Post-Lab:

1. Control the Position of servomotor for every 5 Degrees and serial monitoring
#include <Servo.h>
Servo myservo;
void setup()
{
myservo.attach(9);
Serial.begin(9600);
}
void loop()
{
int pos;

for (pos = 0; pos <= 180; pos += 5)


{
myservo.write(pos);
Serial.print("The Current Position is ");
Serial.print(pos);
Serial.println(" Degrees");
delay(500);
}
for (pos = 180; pos >= 0; pos -= 5)
{
myservo.write(pos);
Serial.print("The Current Position is ");
Serial.print(pos);
Serial.println(" Degrees");
delay(500);
}
}
2. Write a program to control servo motor with Potentiometer

#include <Servo.h>

Servo myservo;

int potpin = A0;


int value;

void setup()
{
myservo.attach(9);
Serial.begin(9600);
}

void loop()
{
value = analogRead(potpin);
value = map(value, 0, 1023, 0, 180);
myservo.write(value);
Serial.print("The Position of the Servo motor is ");
Serial.print(value);
Serial.println(" Degrees");
delay(1000);
}

Evaluator Remark (if Any):


Marks Secured: out of 50

Signature of the Evaluator with Date

You might also like