C_Experiment_5
C_Experiment_5
Experiment - 5
Objective –
Components Required –
1. Arduino Board
2. USB Cable
3. Servo Motor
4. Jumper Wires
A. Circuit Diagram:
B. Steps:
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:
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 –
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.
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.