I am new to the arduino and I was tinkering with the arduino's 5V pin for powering a DC motor. The motor worked fine but I wanted to know
if there is a way to control the motor (on and off ). That is possible on the digital pins (LOW and HIGH) but is it possible on the 5V pin?
If yes then what is the pin no. of the 5V pin to be used in the sketch?
Also, is there a way to reverse the rotation of a DC motor by electronically reversing the polarity of the GND and the 5V pins?
I'm aware that the rpm of a DC motor is fixed, but can I change it by increasing the voltage between the two pins 5V and GND?
Also, what if I wanted to use the arduino to control something which requires a much higher voltage, like a ceiling fan? How do I connect this external voltage to the arduino? I know that wrong wiring and high voltage can fry the processor, so I'd like to be extra careful about this...
You're very lucky you didn't fry your Arduino. Never power a load like a motor from either the 5V or an i/o pin. They can't provide enough current. You get more out of the 5V than the i/o pins though, but still not enough.
Simple way is to use a transistor to act as the switch of an external power supply. You control the transistor as if it was an LED. Have a look here for example, don't omit the diode. You can vary the speed with PWM on the pins marked ~ with analogWrite().
For direction control you need an h-bridge; here's a nice example.
Hey JimboZA
Thanks a lot. I searched for H-bridges and they seemed quite useful to me.
I dont know how to implement external power supply to loads like a dc motor. I mean can i have a separate power supply (5V) for the arduino and a separate one (>5V) for the motor? If yes then can you please tell me about how to assemble the circuit of the same.
I quite don't know how transistors work, but I'll sure try to learn...
Thanks for the help
Yes you would often have separate supplies for the Arduino and the motor. The Arduino can get its power any way you prefer (5V usb from laptop, 7-12V in the barrel jack for example.). When using an h-bridge chip, the motor power actually goes to the chip, and the chip passes it to the motor.
Have a look at the attached. It doesn't show the power to the Arduino (eg usb), but it shows 5V from the Arduino to the 298 to power the chip. The motor -ve and the Arduino GND must be connected together.
The 298 is old technology though and the Pololu solutions are smaller and more efficient.