5
$\begingroup$

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:

Circuitry 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.

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

5 Answers 5

6
$\begingroup$

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.

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

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.

Driving a motor with an NPN transistor.

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.

Added:

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.

High Side Driver

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.

$\endgroup$
1
  • $\begingroup$ 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? $\endgroup$ Commented Feb 13, 2013 at 2:36
3
$\begingroup$

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). Polulu Zumo Shield Arduino Motor Shield Polulu Dual Motor Driver Shield

$\endgroup$
0
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Looks like the video link is broken (changed to private). $\endgroup$
    – JYelton
    Commented Apr 24, 2016 at 22:34
0
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ I have an L293D bridge, but I couldn't get it to work. Would you like to point me to a tutorial? $\endgroup$ Commented Feb 15, 2013 at 3:19
  • $\begingroup$ @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. $\endgroup$ Commented Feb 21, 2013 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.