0% found this document useful (0 votes)
5 views4 pages

C_Experiment_5

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)
5 views4 pages

C_Experiment_5

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/ 4

Course Code - MC1030Course Name - Arduino, IoT FAB Lab.

Experiment - 5

Aim - Speed control of a servo motor using Arduino.

Objective –

1. Speed control of a Servo motor in a real-time environment as a Servo motor is applicable in


various robotic applications.

Components Required –

1. Arduino Board
2. USB Cable
3. Servo Motor
4. Jumper Wires

Circuit Diagram and Theory –

A. Circuit Diagram:

Department of Mechatronics Engineering


Page 1 | 4
Course Code - MC1030Course Name - Arduino, IoT FAB Lab.

Figure. 1: Circuit diagram of an Arduino controlled Servo motor.

B. Steps:

Controlling Servo Motor Speed with Arduino:

 The speed of a motor can be controlled by varying the Pulse Width Modulation (PWM) of
the control signal.
 Arduino generate a PWM signal given by the user, and further PWM signal is responsible
for actuator speed control.
 To control the speed of a motor, you need to connect the signal pin of the servo motor to
one of the digital pins of the Arduino board.
 Then, you need to write a program that generates a PWM signal using the analog Write ()
function.

The PWM signal should have a frequency of 50 Hz and a duty cycle that corresponds to the desired
speed of the motor.

 To control the speed of a motor with Arduino, the following steps should be followed:
 Connect the servo motor to the Arduino board.
 Include the Servo.h library in the Arduino sketch.
 Initialize the motor object using the Servo class.
 Set the initial position of the servo motor using the write () function.
 Use the write Microseconds() function to control the speed of the servo motor by varying
the pulse width of the control signal.

C. Code:

1) To control steps of the Servo Motor


 #include <Servo.h>
 Servo myservo;
 void setup() {
 myservo.attach(9);
Department of Mechatronics Engineering
Page 2 | 4
Course Code - MC1030Course Name - Arduino, IoT FAB Lab.

 myservo.write(90);
 }
 void loop() {
 for (int i = 0; i <= 180; i++) {
 myservo.writeMicroseconds(map(i, 0, 180, 1000, 2000));
 delay(15);
 }
2) To control angle of the Servo Motor

 #include <Servo.h>
 Servo myservo;
 void setup ()
 {
 myservo.attach (6);
 }
 void loop ()
 {
 myservo.write (90);
 delay (1000);
 myservo.write (0);
 delay(1000);
 }

Additional Tasks –

1. Control position of the Servo motor using Ultrasonic sensor.

Conclusions –

The DC motor speed control is an important task to control various robotics systems. In this
experiment students have gained knowledge about how to interface Arduino and motor with PC.

Department of Mechatronics Engineering


Page 3 | 4
Course Code - MC1030Course Name - Arduino, IoT FAB Lab.

They have also studied how to control the speed of a DC motors in a real-time world. To accomplish
the experiment markable safety measures have been taken care.

Department of Mechatronics Engineering


Page 4 | 4

You might also like