Go Down

Topic: motor with arduino! (Read 1 time) previous topic - next topic


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) :)


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


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: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


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


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);


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: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


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


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: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


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.

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

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131