Poll
Question: how to connect motor to arduino?
analog - 1 (14.3%)
digital - 6 (85.7%)
Total Voters: 7

Pages: [1]   Go Down
Author Topic: motor with arduino!  (Read 829 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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) smiley
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8933
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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".
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8933
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8933
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Holland
Offline Offline
Jr. Member
**
Karma: 0
Posts: 93
Troubles are there to be solved!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: May 09, 2012, 02:52:53 am by nickn4 » Logged

humankind cannot obtain anything without
sacrificing something of equal value.

Pages: [1]   Go Up
Jump to: