My toy dc motor runs just fine when connected directly to a 9V battery but when it is combined with arduino, transistor, resistor, and a diode it stops working.
First I connected it with just the transistor and resistor and powered the arduino using the USB cable - didn't work
Second, I put a diode parallel to the motor - didn't work
Then I powered the arduino externally - didn't work
Then I put an external 9V battery in the motor - still didn't work
I just followed the circuit and the code in this tutorial: How to Spin a DC Motor with the Arduino - dummies
What am I doing wrong here? Thanks in advance!
Please make a simple pencil drawing showing exactly how YOU have connected everything and give details of the transistor you are using and post a photo of the drawing.
In general it is not a good idea to power a motor from the Arduino 5v pin because the motor can draw too much current and upset (or damage) the Arduino.
If you use an external motor power supply make sure that its GND is connected to the Arduino GND.
What value resistor?
That article is pretty poor, the 2k2 resistor should be 150 ohms or so, and the transistor needs to be a high
current NPN switching transistor, a 2N2222 or better. Standard small signal transistors like a BC547 will
simply fry trying to drive most small motors, since they handle 150 to 250mA typically, and motors
draw 0.5 to 1A typically. PNP transistors will not work (and will probably be fried too).
That article is also hopeless because it assumes there is only one pinout for a transistor for each
style of case, and there are several, and you must look at the datasheet for the particular transistor
Those transistor pictures are reversed from what I'm used to, looking at the flat side of a TO92 it
should be usually is EBC for 2N2222, 2N3904, etc.
Too many believe there is a standard pin out for BJTs - there isn't really. Even the same partnumber
can be available with different pinouts I've found. There are two pinouts for TO92 that are the commonest,
and metal canned transistors tend to be EBC counting from the tab, but basically check the datasheet
or use a transistor tester.
Thanks for the reply! I will try your suggestions.
Yeah I used a 2.2k ohm resistor. And I also forgot to tell you that the transistor becomes heated so much so maybe the pin connections were wrong.
UPDATE: It is working now! I just switched the transistor’s pins and lowered the value of the resistor. Thanks!