Go Down

Topic: motor with arduino! (Read 884 times) previous topic - next topic

filipeishon

hi every one, im trying, to move a motor with the arduino, im new at arduino, its a motor of 6 volts, i have conected the batery to arduino, but i don't now how to connect the motor, in analogs, in digitals, i dont know where.
thank you for help me(sorry for my bad english) :)

johnwasser

If the motor draws more than about 30 mA (and it probably does) you will need a transistor to switch the power:

http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/

If you want to vary speed with software, use a PWM output and "analogWrite()".

If you want to reverse direction you will need an H-bridge.  Look for a "motor shield".
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

filipeishon

thank you, you are my savior! you are the best! thank you!

filipeishon

this will be okay for the motor?
int motorPin = 9;
void setup()
{
pinMode(motorPin, OUTPUT);
}

void loop()
{
int onTime = 2500;
int offTime = 1000;

analogWrite(motorPin, HIGH);
delay (onTime);
analogWrite(motorPin, LOW);
delay (offTime);
}

johnwasser

That won't work well because "HIGH" is defined as 1.  You'd be switching between OFF (0) and 1/256th on (1) which is almost the same thing.  If you want on-off control use digitalWrite() with LOW for OFF and HIGH for ON or use analogWrite() with 0 for OFF and 255 for ON.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

filipeishon

thank you! but the digitals pins pwm are positive? i don't now please help me!

johnwasser


thank you! but the digitals pins pwm are positive? i don't now please help me!


I don't understand your question.  Please try again.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

nickn4

#7
May 09, 2012, 09:49 am Last Edit: May 09, 2012, 09:52 am by nickn4 Reason: 1
if u mean that u can use pwm pins as power suply the anwser is: depending on the current-draw of the motor, yes (btw there is no max-Voltage differnce between digital and pwm..)
the arduino i/o pins can output max 40 mA. for example: if the motor is drawing 200mA u will need to connect the motor serpartly to a power source, than use a transistor like mentionted by johnwasser.

lots of these stuff is also all around the net (hint: google)
just search and you will find, when u still dont understand something its worth posting.

nick
humankind cannot obtain anything without
sacrificing something of equal value in return.

Go Up