I'm trying to repair a Home Depot Lunging Witch Halloween prop I got on clearance for $25. I'm replacing the fried circuit board with an arduino. I've got everything else to work, but the motor won't turn on.
So, to test my circuitry, I built a simple motor circuit and sketch. I followed this example here (but I'm using a 2k resistor instead of 2.2K):
I can get it to work perfectly with a spare little dc motor I have, but not with the real motor I need to use.
Maybe one of my 2N222A transistors is bad because one of the 2N transistors causes the motor to be on constantly... I can't turn it off. All my other 2N transistors never turn ON the motor.
Now, here's the funny thing... using a multimeter, I'm getting 4.93V for the 2 wires I connect to the motor NO MATTER whether I use the bad transistor or one of the good transistors. With the good transistors, my multimeter shows 4.93V for 4 seconds, then it shows 0V for 4 seconds... just like it should, but the motor never turns on. With the bad transistor, it just constantly shows 4.93V and the motor never shuts off.
I need to use this specific motor because it has to fit within a plastic case with lots of gears. The prop calls for a 5.9V power adapter to run, so I'm just running the sketch off my USB port. I have no idea what the specs on the motor are. I don't see any numbers anywhere on it.
Here's my simple code:
const int motorPin = 9; // the number of the motor pin
void setup() {
// initialize the motor pin as an output:
pinMode(motorPin, OUTPUT);
}
void loop() {
digitalWrite(motorPin, HIGH);
delay(4000);
digitalWrite(motorPin, LOW);
delay(4000);
}
First, why doesn't the motor turn on/off as desired? Second, is that one transistor really bad or not?
elyders:
But, I can. I have another dc motor that works just fine. The halloween prop motor I'm trying to use gets powered, too, but I just can't shut if off.
Thanks for measuring the motors resistance.
Oh, and thanks for the image of your wiring.
Well, I guarantee you will burn up your UNO then.
Sounds like you do not want any advise from us, good luck.
Simple and easy to use.
Often I buy a few of the cheap Chinese modules to do the job.
But if you can salvage any from old computer power supplies they will often work just as well.
Seeing as it calls for OVER 5 volt consider a better power supply too !
Larry gave you the right idea as USB ports can only supply limited current and you probably need more than it can handle.
2k or 2k2 is about 2mA base current, and only good for <=40mA collector current.
A toy motor is likely using way more than that.
That low base current is not fully saturating the transistor switch, and the higher volt drop will cause the transistor to internally heat up and likely pop it's top.
For a motor <=500ma you should at least drive the base with ~20mA.
Try a 220ohm resistor (and a new transistor).
There are two different pinouts for the "2222". Make sure you use the right one (check the datasheet).
Leo..
outsider:
One motor lead to +V, other lead to 2N2222 collector, 2N2222emitter to GND, your image doesn't look like that to me, unless the transistor leads are backward. https://www.fairchildsemi.com/datasheets/PN/PN2222A.pdf
Viola! That was it! My wires were backwards. Well, my wires were correct according to the example I was going off of, but I never knew there were 2 types of BJT transistors: NPN and PNP. I'm using the NPN, so my wires are Emitter, Base, Collector. The example I was following was using PNP, so it was showing CBE.
elyders:
Viola! That was it! My wires were backwards. Well, my wires were correct according to the example I was going off of, but I never knew there were 2 types of BJT transistors: NPN and PNP. I'm using the NPN, so my wires are Emitter, Base, Collector. The example I was following was using PNP, so it was showing CBE.
I just started using arduino this week, so I appreciate everyone's help and suggestions.
I'm still confused why the other dc motor worked perfectly.
Oh well, live and learn.. as long as I don't kill myself.
The 'other' motor worked because it uses far less current than the one you want to use. Powering components that use a lot of current from the power pin of an Arduino puts the components on the Arduino board at risk of being damaged. Use an external power supply, and power both the Arduino and motor from that power supply. Be sure and use protection circuitry between the motor and the power supply.
By the way, I liked your first diagramming style a LOT more than the Fritzy you have in your last post.
Well, after all of the trouble I went through getting a dc motor to work, I decided it would be safer, and easier, to use servo motors to move my halloween prop. I'm going to stay away from dc motors for now.