[go: up one dir, main page]

0% found this document useful (0 votes)
16 views16 pages

Unit-3 4

The document discusses interfacing DC motors and servo motors with Arduino. It describes the components of DC and servo motors and provides examples of coding in Arduino to control the speed and rotation angle of DC and servo motors respectively.

Uploaded by

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

Unit-3 4

The document discusses interfacing DC motors and servo motors with Arduino. It describes the components of DC and servo motors and provides examples of coding in Arduino to control the speed and rotation angle of DC and servo motors respectively.

Uploaded by

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

UNIVERSITY INSTITUTE OF ENGG.

DEPARTMENT OF ECE
Bachelor of Engineering (Electronics And Communication
Engineering)
Arduino Based System Design
Interfacing Motor with Arduino

DISCOVER . LEARN . EMPOWER


Outcomes
Upon completion of this Lecture, you will be able to

• Know DC and Servo Motor


• Know interfacing of DC Motor with Arduino and control its speed.
• Know programming of of DC Motor.
• Know interfacing of Servo Motor with Arduino and control its rotation angle.
• Know programming of of servo Motor and related examples
Main Contents
1 DC and Servo Motor

2 DC Motor Interfacing with Arduino

3 Arduino Coding for DC Motor

4 Sevo Motor interfacing and programming


Motor

DC Motor Servo Motor


• A DC motor (Direct Current motor) is the most • A servo (short for servomechanism) contains an
common type of motor electric motor that can be commanded to rotate to
• DC motors normally have just two leads, one a specific angular position.
positive and one negative. • It’s easy to connect a servo to an Arduino because
• If you connect these two leads directly to a battery, only three wires are involved.
the motor will rotate. • If you’re using the HXT900 as shown in fig., the
• If you switch the leads, the motor will rotate in the darkest wire connects to GND, the center wire
connects to 5 V, and the lightest wire (the pulse
opposite direction.
wire) connects to a digital pin.

4
Selecting DC Motor
• The operating voltage This can vary, from 3 V to more than 12 V.
• The current without a load The amount of current the motor uses at
its operating voltage while spinning freely, without anything connected
to the motor’s shaft.
• The stall current The amount of current used by the motor when it is
trying to turn but cannot because of the load on the motor.
• The speed at the operating voltage The motor’s speed in revolutions
per minute (RPM).

5
Interfacing DC Motor
We will do three program examples with DC motor -
• Just make your motor spin
• Control motor speed
Components required
• 1x Arduino UNO board
• 1x PN2222 Transistor
• 1x Small 6V DC Motor
• 1x 1N4001 diode
• 1x 270 Ω Resistor

7
Interfacing Diagram

8
Example 1 for Spin Control
int motorPin = 3;
void setup()
{
pinMode(motorPin, OUTPUT);
}
void loop()
{
digitalWrite(motorPin, HIGH);
}
9
Point to be note
• The transistor acts like a switch, controlling the power to the motor.
• Arduino pin 3 is used to turn the transistor on and off and is given the
name 'motorPin' in the sketch.
Result
• Motor will spin in full speed when the Arduino pin number 3 goes
high.

10
Example 2 Motor Speed Control
void setup()
{
pinMode(9, OUTPUT);
}
void loop()
{
u for (int a=0; a<256; a++)
{
analogWrite(9, a);
delay(100);
}
delay(5000);
for (int a=255; a>=0; a--)
{
analogWrite(9,a);
delay(100);
}
delay(5000);
}

11
Result
• The DC motor will spin with different speeds according to the value (0
to 255).

12
Selecting a Servo Motor
When you’re selecting a servo, consider several parameters:
• Speed - The time it takes for the servo to rotate, usually measured in seconds per angular
degree.
• Rotational range - The angular range through which the servo can rotate— for example, 180
degrees (half of a full rotation) or 360 degrees (one complete rotation).
• Current - How much current the servo draws. When using a servo with an Arduino, you may need
to use an external power supply for the servo.
• Torque - The amount of force the servo can exert when rotating. The greater the torque, the
heavier the item the servo can control. The torque produced is generally proportional to the
amount of current used.

13
Example 4 - Servo motor rotation angle
control
• #include <Servo.h> // servo library
• Servo myservo;
• void setup()
• {
• myservo.attach(4); // Servo is connected to digital pin 4 of arduino
• }
• void loop()
• {
• myservo.write(180); // servo will rotate between 0 to 180 degree
• delay(1000);
• myservo.write(90);
• delay(1000);
• myservo.write(0);
• delay(1000);
• }
14
Applications of Servo Motor
• servos are used in radio-controlled airplanes to position control
surfaces like the elevators and rudders.
• They are also used in radio-controlled cars, puppets, and of course,
robots.
• Servos are extremely useful in robotics. The motors are small, have
built-in control circuitry, and are extremely powerful for their size

15
THANK YOU

You might also like