Go Down

Topic: Motor wont turn off? (Read 79 times) previous topic - next topic

Zawszeyi

Hi guys, newbie here.
I bought an arduino mega to do some uni work, and was just playing around with a motor. I followed these exact steps:

https://www.dummies.com/computers/arduino/how-to-spin-a-dc-motor-with-the-arduino/

with the same code.

However, when I plug the arduino in, the motor works just fine, but when i try to upload code to change its speed nothing happens? I tried uploading and compiling an empty code, but the motor still wont turn off. Tried hardware reset button etc, but still nothing.

Any ideas?

Cheers.

Zawszeyi

Maybe im just uploading it incorrectly? Im just pressing the upload button on the Arduino ide.

MarkT

That article has several mistakes, frankly its awful.

Firstly you need to know the stall current of the motor before doing anything - that determines
what kind of switching device will be adequate.  If it is 1A or more you'll really need a logic-level MOSFET,
not a BJT (although a darlington will do at a pinch).

Secondly the explanation given about the need for the diode is complete garbage.  The diode prevents
high voltage inductive kickback pulses from destroying the transistor.  Such precaution is always
needed when switching an inductive load like a motor, relay, solenoid...

Thirdly the circuit they give shows a 2k2 base resistor, which is way too large.  150 ohms is a more
reasonable value for driving a BJT into a small motor.  Their circuit will probably overheat the
transistor and lead to disappointingly sluggish response of the motor.

Fourthly they show the motor being powered direct from the Arduino's 5V rail - this is a bad
idea.  Motor power should be separate from the 5V logic supply (which is sensitive to dropouts
and spikes that motors will impose on their supply).

As to your problem, you'll need to post your code.  My first guess though is that you might
have fried your transistor already, or that you've parked the output pin HIGH.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Zawszeyi

Thank you for your detailed response. As for my code, it is exactly as the website says, which I have attached.
I have also tried to attach a picture of my setup, but the angle isnt that great.
Hopefully it helps.

MarkT

Probably the hardware then.  You need to provide all the details if you want insight into that.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up