# High voltage motor control with arduino

I'm trying to control a higher voltage motor than an arduino can source with a pin, with an arduino. I am trying to hook it up to a transistor. The battery pack is not supposed to be 4.8V, it's 6V, 4 D batteries.

Here is the setup:

Here is the arduino code I'm trying to run to it:

int motorpin = 2;

void setup()
{
pinMode(motorpin, OUTPUT);
}

void loop()
{
digitalWrite(motorpin, HIGH);
delay(500);
digitalWrite(motorpin, LOW);
delay(500);
}


Code gives me no errors, but no motor movement happens. What would make this work? Thanks.

• Did you ever get this sorted out? I have been working with this same circuit and not having issues. – Kenn Feb 12 '13 at 15:50
• Completely out of context but, what did you use to make that image? – Chandough Jun 13 '14 at 15:26
• You have only one wire to arduino? where is source power? – Elan Morales Nov 7 '16 at 5:27
• @Chandough That looks like a Fritzing schematic. – wyverniv Nov 13 '16 at 2:17

Your hardware configuration sounds wrong... your trying to provide all the drive current from the arduino

Given your description, your using a bipolar (NPN or PNP) transistor, I'd wire up as:

• Base: To arduino
• Collector: Motor -ve (motor +ve to Vcc)
• Emmitter: Ground

Alternatively:

• Base: To arduino
• Collector: Vcc
• Emmitter: Motor +ve (motor -ve to Ground)

This way, the processor is switching the current flow between Vcc and the motor, not supplying all the power.

• Actually, it's a NPN transistor. I'm not sure if that makes a difference. – Elias Benevedes Feb 10 '13 at 15:49
• No, the answer applies to either (answer tweaked) - and actually NPNs are more common than PNPs in this scenario – Andrew Feb 10 '13 at 17:03
• Still not working, DAMN this is frustrating. I feel like I should EASILY be able to do this! – Elias Benevedes Feb 10 '13 at 23:05

It's possible that this isn't working because you have blown your transistor. There are a couple of things which could have blown it:

• No resistor to limit the base current
• No diode to protect against back EMF from the motor

So you should add a base resistor, and a flyback diode.

I always like to add an LED to the Arduino's output too, so that I can see exactly when the output is high. And if you're doing PWM on that pin, then the brightness of the LED tells you the duty cycle.

The reason for putting the transistor below the motor is that it's easier to make it work. To switch on the transistor, I just have to push a little current through the base by bringing its voltage up higher than the emitter. But if the transistor was above the motor, and the motor was running at 12v, then it's going to be impossible for the Arduino to do this, because it can't generate a voltage high enough.

When you put the transistor above the motor, you need to add another transistor to help you deal with the large voltage required by the base.

In this circuit they're using a FET, rather than an NPN transistor, so the base is called a gate, but the same thing applies.

• Lemme try that. I never thought it might be the transistor. And BTW, why do you have the transistor set up as so? Is that an PNP in the picture, or NPN? – Elias Benevedes Feb 13 '13 at 2:36

And for the 'I'd rather be designing the sensors and grippers' of us, consider a ready made motor shield for Arduino such as:

Polulu Zumo Shield (1.2 amp motors) or the Arduino Motor Shield (2 amp motors) or the Polulu Dual Motor Driver Shield (3.0 amp motors).

I actually just ran into this and I found that my resistor going from my Arduino pin to the base was wrong. You might want to watch this video. It was very useful for me. http://www.youtube.com/watch?v=DLl7-CmVT7w

• Looks like the video link is broken (changed to private). – JYelton Apr 24 '16 at 22:34

You need first to know how much current your motor draws at no load, and also at stall. After that you need to choose a transistor that its collector or its drain can support the stall current.

You have to know that your current configuration is just for a one direction control, and to which direction that depends on the polarity.

You need an H-Bridge like L293-L298 for controlling in two directions.

• I have an L293D bridge, but I couldn't get it to work. Would you like to point me to a tutorial? – Elias Benevedes Feb 15 '13 at 3:19
• @EliasBenevedes It is very simple. Just connect VS to 12V and that depends on your motor supply voltage, connect the ground, then use the the two inputs according to the truth table in the datasheet. Do Not forget to put the protection diodes. – Ahmed Saleh Feb 21 '13 at 18:31