Build Your Own Motor Driver

by Anshu AR in Circuits > Arduino

45608 Views, 361 Favorites, 0 Comments

Build Your Own Motor Driver

Cover.JPG

Hello everyone,

In this instructable we'll be making our own motor driver using transistors.

In my last attempt to use transistor as motor driver I was unable to control the speed of the motor using it.

But, Thanks to valuable comments from instructables users who suggested me to use PWM pins to control motor speed and to improve the circuit. So, this circuit is able to control motor speed using PWM pins, protect arduino and other electronics from back emf and electrical noise generated by the DC motor.

Gather the Parts

Parts.JPG
  1. An Arduino
  2. A breadboard
  3. A 220ohm resistor
  4. A 2N2222 transistor
  5. A IN4001 diode
  6. A 0.1 microfarad ceramic capacitor
  7. A DC motor
  8. A 9V battery
  9. Some jumper or hookup wires

Wiring

Wiring 01.JPG
Wiring 02.png
Wiring 03.png

Hookup all the components according to the circuit diagram shown above.

Why we need a A 0.1 microfarad ceramic capacitor in parallel with the motor?

When DC motors operate they produce a lot of electrical noise, The main cause of this noise is the brushes of the brushed DC motor.

These noise can interfere with the sensors and even impair the micro-controller.

That's why we need a 0.1 microfarad ceramic capacitor in parallel with the motor.

Why we need a IN4001 diode in parallel with the motor?

When the DC motor is turned OFF or current being changed across the motor, The motor generates Back EMF.

This back emf can damage electronics or can cause data loss.

To counter this we need a IN4001 diode in parallel with the motor.

The Code

Code 02.PNG
Code.JPG

Upload the following code to arduino.

The following code runs the motor at a Higher speed for 10 sec and then lowers the speed for the next 10 sec.

int MotorPin = 10;

void setup()

{

pinMode(MotorPin, OUTPUT);

}

void loop()

{

analogWrite(MotorPin, 200); //Any value between 0 to 255

delay(10000);//Wait for 10 secs

analogWrite(MotorPin, 100); //Any value between 0 to 255

delay(10000);//Wait for 10 secs

}

Downloads

Done

Done.JPG

Now Power the arduino and see your motor spinning with varying speeds.

Thanks for viewing.

Please write your questions or suggestions below.