I have a small dc motor that I want aduino(uno) to control lets say I connect I connect it to the input labeled as 4 and 5(which if it was a LED would mean use digitalWrite(4, HIGH)) what should I do to make it turn the motor on? even if it just means to power it on? I tried to leave it as (digitalWrite(4, HIGH);) but it didnt work btw Im an expert with computer programmes but a noon when it comes to arduino any help would be highly appriciated
Yes you would do this digitalWrite(4, HIGH); but first in setup you do pinMode(4,OUTPUT);
BUT you can't wire up a motor directly to a pin you need some sort of driver. See this link:-
I dont know a lot about drivers isnt there a way to do it without one? bacuse I would imagine a driver is needed to actually interact with the motor but just sending power and withholding power from port 4 and 5 would do the trick how do I do that like code that would mean turn on power for port 4 and 5 has anyone done what I want to do and can send me a driver/a code like a suggested?
I dont know a lot about drivers isnt there a way to do it without one?
No. The arduino pin can only supply 30mA or so, this is way less power than a motor takes, so you need a transistor, FET or relay to switch the power.
power from port 4 and 5
You only need one pin to turn a motor on and off, roping in another port make things worse.
like code that would mean turn on power for port 4 and 5
Just gave it you in the last post.
The driver in this case is nothing to do with software, its hardware (see GM's link) A motor draws too much current to be driven directly from a microcontroller and needs a circuit to feed the motor enough current without damaging the Arduino. Its all in GM's link.
tomer, The motor likely requires more current than an arduino outpin can provide ( that is, more than 30-40mA). So you need a 'driver', which is basically just a transistor that the arduino Can provide enough current to turn on, and when the transistor turns on it allows a lot more current to flow to the battery from a larger source (such as a wallwart, or batteries). You will damage the arduino output pins beyond repair driving the motor directly. It will try for sure, but it only has little tiny transistors and they break easy.
I really suck at physics you said that the arduino gives up to 30mA I want to know how much volts it supplies so I can buy a transistor
I have IE8 - do you recall how I said I managed to avoid the image overlap on your pages? I don’t remember what I did a couple of months ago.
The transistor depends on your motor. Do you have any data on it?
The arduino uno only puts out 5V.
If you tell us where you are located, we can suggest a transistor and where to get one.
I live in Israel
and 5v is exactly what my dc motor needs
I want to know how much volts it supplies so I can buy a transistor
I doubt if you can buy a transistor that has so low a voltage it won't work on an arduino. The transistor you will use will have a much higher voltage rating but that is no problem.
CrossRoads - I think you looked at it with Fire Fox.
and 5v is exactly what my dc motor needs
Yes but needs more current, hence a transistor.
GM - thanks, knew it was something simple. I tried Chrome, that opened it nicely.
tomer, Try these guys, I would call, their online catalog doesn't seem to work. http://www.lion.co.il/en/semiconductors.html Or search for similar sites.
actually I checked and it puts out 2.5v which is actually the problem. the current would be right if it put out 5v is it possible to connect it to 4 pins so I can get the 5v I need?
actually I checked and it puts out 2.5v which is actually the problem.
Is that with the motor connected or not? Is the pin defined as an output?
the current would be right if it put out 5v
No it wouldn't.
its connected and pinMode(4, OUTPUT)- its connected to pin 4 and 5 it requires 5 volts, can I or cant I connect it to 4 pins to achieve 5 volts?
You can not connect a motor directly to any arduino pin.
it requires 5 volts, can I or cant I connect it to 4 pins to achieve 5 volts?
Or even four of them.
Just connect the pins 1 -10 to (+) and (-) ground. Turn all 10 pins ON at the same time. Each pin will give 40 mA (according to spec) Tadaaaaaa 400 mA to you motor ]:D ]:D ]:D ]:D
NO NO NO - bad friday joke !!!!
You need a transistor and a diode (and those are rather cheap). Look at the first scematics on the page Mike has linked to.
why would I need a diode? the motor is not a power source therefor will power back the arduino wouldnt a diode be useless in this scenario?
wouldnt a diode be useless in this scenario?
Well, you may or may not destroy your transnstor without one. The laws of physics generally ignore wishful thinking.