Hello Adruino Community,
I'm in need of some help with project 09 (motorized pinwheel). I've done virtually everything I could think of to get this to work. Every time I create the circuit the motor begins to spin on its own. I've rebuilt the circuit multiple times with different parts (i.e., transistor, switch, etc.). Moreover, I've redone the code multiple time with no luck. Lastly, I've even tried multiple orders (e.g., uploading the code first then circuit), and still, the motor spins as soon as I connect the 9V. Can someone please help!!! Attached is my circuit and code.
My first guess is that the transistor is wired wrong. Transistor pin outs are not all the same. What is the part number of your transistor? Do you have a data sheet for it?
I can't tell where the resistor on the switch goes. Here is how to wire a switch with pull down resistor.
Thanks for the reply groundFungus. The transistor that came with the my particular starter kit is PN2222. The booklet shows a different transistor than the one that I have.
When you start a new project, one of the first things to do is to acquire the data sheets for all the parts that you can.
Here is the data sheet for PN2222.
The pin out, with the flat side of the transistor facing you and left to right is: emitter, base, collector. The emitter should be wired to ground, the collector to one wire of the motor (the other wire to the motor power source). and the base to a digital output through a 180 to 470 ohm resistor. The resistor between the base and the output pin is important as it limits the current into the base and protects the output pin. Any tutorial that omits that resistor is crap.
You may get away with powering a small motor from the Uno 5V but the motor should be powered with an external supply (2 AA batteries would be good).
Thanks again groundFungus! I'm going to give this a shot to see if I can finally get this to work.