Introduction: Use Transistor As Motor Driver : Basic

Picture of Use Transistor As Motor Driver : Basic

Hello everyone, In this instructable we will be using transistor as a Motor Driver.

Actually, We can't say it as a Motor Driver as it can just toggle motor ON or OFF rather than controlling the motor speed or direction.

But, Using the transistor protects our Arduino from burning out. As ordinary DC motors runs on High Amps or consume more current than what an Arduino can supply.

Step 1: Gather the Parts

Picture of Gather the Parts

  • An Arduino
  • A breadboard
  • A 220ohm resistor
  • A 2N2222 transistor
  • A DC motor
  • A 9V battery
  • Some jumper or hookup wires

Step 2: Wiring

Picture of Wiring

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

Step 3: The Code

Picture of The Code

As I mentioned above we can just toggle motor ON or OFF.

So, The following code turns the motor ON for 10 sec then turns it OFF for 5 sec and cycles through the process.

void setup() {

pinMode(13, OUTPUT);

}

void loop() {

digitalWrite(13, HIGH); // Turn the motor ON

delay(10000); // Wait for 10 secs

digitalWrite(13, LOW); // Turn the motor OFF

delay(5000); // Wait for 5 secs

}

Step 4: Done

Picture of Done

Now Power the arduino and see your motor spinning.

Thanks for viewing.

Please write your questions or suggestions below.

Comments

RobBest (author)2016-07-19

This circuit seems a bit strange to me. You use a 9 Volt battery for the Motor but you control the transistor from the Arduino in a circuit called an emitter follower. This means that the voltage over the Motor will not be larger than the voltage of the Arduino (I assume 5 Volt) minus the base-emitter Voltage drop which is about 0.7 Volts. So the maximum Voltage over the Motor is 4.3 Volts and so you do not need a 9 Volt battery but you can supply it with the 5 Volt of the Arduino. Next to that you need a dioide in parallel with the Motor since the Motor will generate a negative voltage spike as soon as you stop controlling it. The Diode must be connected with the cathode to the emitter of the transistor and with the anode to ground.

Anshu AR (author)RobBest2016-08-07

Yep!

But the circuit works great.

And yes, I do need to consider about the back emf from the motor.

Time to update my instructable.

DylanD581 (author)2016-07-18

This is great for making a remote control vehicle.

Anshu AR (author)DylanD5812016-08-07

Do try.

I would love to see that.

Smelter_uk (author)2016-07-19

You should be able to vary the speed of the motor using a PWM pin. Time to experiment!

Anshu AR (author)Smelter_uk2016-08-07

Yeah!

PWM pins work great to change the motor speed.

Nematic! (author)2016-07-19

appreciated but instead of transistor use mosfet because they can handle higher current

rafununu (author)Nematic!2016-07-19

Mosfets are transistors as well.

About This Instructable

3,375views

97favorites

License:

Bio: So, I got a bunch of LEDs when I was 8 or 9 something.
More by Anshu AR:Scratch Built RC AirplaneH Bridge Motor Driver For Arduino Using TransistorsHow To Use A Piezo To Produce Tone : Basics
Add instructable to: