Build Your Own Motor Driver

40,497

361

37

Introduction: Build Your Own Motor Driver

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.

Step 1: Gather the Parts

  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

Step 2: Wiring

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.

Step 3: The Code

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

}

Step 4: Done

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

Thanks for viewing.

Please write your questions or suggestions below.

Maker Olympics Contest 2016

Participated in the
Maker Olympics Contest 2016

Makerspace Contest

Participated in the
Makerspace Contest

Be the First to Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • Make It Bridge

      Make It Bridge
    • For the Home Contest

      For the Home Contest

    37 Comments

    0
    BambiB
    BambiB

    6 years ago

    Massive overkill to use an arduino for this. If you just want to control speed, a 555 timer circuit is WAY cheaper (about a 5-10 cents). If you want to control various intervals, a dedicated processor (ATTINY24/45/85 or ATTINY 13 - less than $1) will do the job.

    For switching applications (PWM), especially in battery-operated circuits, a MOSFET is generally preferred over a BJT because it wastes less power.

    0
    TheFireMan
    TheFireMan

    Reply 6 years ago

    Of COURSE its "massive over-kill"..

    This is an INSTRUCTable.. it's meant to INSTRUCT or TEACH a process or idea..

    It's NOT meant to mini-max or optimize a production item...

    Indeed, the majority of the articles fall under the "teachable moments"...

    0
    BambiB
    BambiB

    Reply 6 years ago

    Well, in that case, why not go out and buy a new MacBook, a USB to serial converter, an arduino and a motor. That way you could have the MacBook send instructions to the arduino, which could then control the motor.

    Oh wait!

    Why not hire someone full time at $100/hour to watch the MacBook, and use a timer to alert them when they should adjust the motor speed.

    Oh wait! Why not have a government department to set rules and conditions and regulations and...

    Part of learning is understanding when a "solution" makes sense, and when it doesn't. If you need programmable motor control, an arduino isn't a bad first approximation. But if you just need motor control - well, maybe you ought to put an ad on line for motor speed watcher guy positions.

    0
    WellActually
    WellActually

    Reply 1 year ago

    Dude, I just did this with a Raspberry Pi Pico ($4 microcontroller) on my school Chromebook, it's just giving the basic idea, you can use any board really. This is just one of MANY methods to do this.

    0
    Francisco JavierC11
    Francisco JavierC11

    Reply 6 years ago

    Hahaha! Really funny dude, Your sarcasm is great!

    #MacBookWatcher vacancy?- dial me

    0
    Aditya vasu
    Aditya vasu

    Question 3 years ago on Step 4

    Can I use this motor driver in voice controlled car

    0
    Ishayu
    Ishayu

    3 years ago

    Can I use a IN4007 instead of IN4001?

    0
    AditiA8
    AditiA8

    Question 4 years ago on Introduction

    Hi! Here you used a 9V source, if we wish to run a 200W motor at 48V, what all specifications will change? And to what extent?

    0
    Anshu AR
    Anshu AR

    Answer 4 years ago

    Hi, you'll probably need to use a MOSFET like an IRF640. With a different circuit.

    I would recommend using Digikey part search to find the MOSFET as per your requirements.

    0
    IbrahimA196
    IbrahimA196

    5 years ago

    hi

    i just want to know how you select 0.1 microfarad capacitor, if i'm going to use higher amps transistor how to calculate the required capacitor or it depends on the motor? also, do you suggest any further components for protection?

    0
    Anshu AR
    Anshu AR

    Reply 5 years ago

    Selection of capacitor basically does not matters.

    It's just a precaution. Just in case you are using this circuit with RC models or such. So that electrical noises doesn't interfare the RC signal.

    0
    tim939
    tim939

    6 years ago

    info-Sam, thank you for posting this! I am new to Arduino stuff and looking forward to building on this instruct able as I work towards creating a small bot as a hobby.

    0
    rjmcnealy
    rjmcnealy

    6 years ago

    Nice work. Could you please suggest components that would control a small 12 V water pump? The pump is 1.5 A at 12v

    0
    Anshu AR
    Anshu AR

    Reply 6 years ago

    Why don't you try relays.

    But you won't be able to control the motor speed.

    0
    jimvandamme
    jimvandamme

    Reply 6 years ago

    Do you need to control the speed, or just turn it on and off? You'll need a higher power transistor, and a FET would be easier to drive.

    0
    Anshu AR
    Anshu AR

    Reply 6 years ago

    I am controlling the speed too.
    Yes, but in this project I used small hobby DC motor that runs on a relatively small amount of current so I used general purpose transistor.

    0
    Israeld7
    Israeld7

    Reply 6 years ago

    The componentes would be the same as listed, but 1.5 amps using 12 volts would need a decent power source. Look for an old router power supply or some speakers powers supply, if they are 12v and 1.5amps (or greater amp) they would make the job.

    0
    CarlosMC
    CarlosMC

    6 years ago

    nice circuit, and very useful information. thanks for the detailed explanation about the need of use diode and capacitor... i'm a lot of cheap toy to make with this and arduino nano.

    0
    Anshu AR
    Anshu AR

    Reply 6 years ago

    Thanks!