I've searched countless tutorials on using a transitor with the arduino UNO and a motor. But, here is the problem. When I power my motors with 9V and then power the transitor with 9V, the motor switches on like I want it too. But when I hook the signal wire from the arduino to the transistor, it does not turn the motor on. What am I doing wrong?
I bet you put the transistor closer to the 9V line than the motor.
Always nice to see a schematic that represents the way the circuit is actually connected.
i took the circuit apart so i cant take a picture. but how do i position the transistor? what do you mean its too close to the 9V line?
LarryD:
Always nice to see a schematic that represents the way the circuit is actually connected.
Yes, and some specs as to which "transistor" might be in question.
My guess is it is a ground issue.
tjrusk12:
what do you mean its too close to the 9V line?
I think it is probably more common to see:
9v > motor > transistor > ground
I think fungus is guessing you did:
9v > transistor > motor > ground
Just guessing.
i took the circuit apart so i cant take a picture.
Don't need or want a picture. Want a schematic.
I think that is what I did. I had this layout ------9V Power-----transistor-----motor----ground
My transistors are NPN 2N2222. I can't draw out a schematic at the moment but I went by the adafruit arduino dc motor tutorial.
Can you draw a schematic on a piece of paper and scan it or take a picture of it? A transistor is not a 2 lead device.
From your description, fungus is correct.
It should go
+12V ---- motor ----- Collector --- Emitter --- Ground
Then Arduino output ---- 1k resistor --- Base
In addition, it would be a wise idea to put a diode across the motor. Anode to 12V side, Cathode to the other side. IE, little triangle pointed at 12V.
I see exactly what I did now. I hooked up my transistor and realized I was using the wrong type of transistor. I'm going to buy some new ones tomorrow since I blew the transistor. I also didn't place a resistor on the base. Is this necessary? Could this be what blew my transistor?
tjrusk12:
I also didn't place a resistor on the base. Is this necessary?
To answer that question....
That link is about MOSFETs.
It is important that you understand how specific kinds of transistors work. You cannot simply put a PNP in that circuit, drive it from 9V, and expect it to work. With the Arduino output High (5V), it will still be driving sufficient current to the base to keep the transistor at least partly on.
tjrusk12:
I think that is what I did. I had this layout ------9V Power-----transistor-----motor----ground
My transistors are NPN 2N2222. I can't draw out a schematic at the moment but I went by the adafruit arduino dc motor tutorial.
For an NPN transistor, you should have had things connected up in this manner:
-
Arduino digital pin to 1K resistor, other side of resistor to NPN transistor BASE
-
+V to motor, other side of motor to NPN transistor COLLECTOR
-
Rectifier diode (1N4004 or similar) across NPN transistor COLLECTOR and EMITTER (cathode to COLLECTOR, anode to EMITTER - cathode is the end with the stripe)
-
NPN transistor EMITTER to GROUND
-
+V to positive of power source for motor
-
GROUND to negative of power source for motor, also connected to Arduino ground pin
You make no mention of the base resistor or the diode - both are absolutely necessary for proper functioning of the circuit, and protection for the Arduino.
You mentioned using 9V to power the motor - if you are using one of those 9V rectangular batteries, bad move. Those won't last at all driving a motor; they can only source around 150 mA or so. Get a proper power source. Also - you don't mention what kind of motor you have...what is it's voltage and current ratings (stall and running currents); if it's stall current needs are greater than what the 9V can put out (a motor at rest, with no power, is considered "stalled") - it likely won't start turning.
You can also put a diode across the transistor, but you really should also have one across the motor.
Reason: With a simple inductor, when the transistor turns off, current continues to flow in the same direction and polarity reverses. Without a diode across the inductor, voltage spikes very high trying to maintain the same current flow (which decays).
With a motor, when the transistor turns off and the motor is still spinning, voltage continues in the same polarity but current reverses. However, in the case of a spinning motor, voltage stays the same at first, decaying as the motor spins down.
But this is complicated by the fact that a motor is also a collection of inductors. That's why I strongly recommend a diode across the motor.