Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

controlling dc motor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

controlling dc motor

by pakun on Mon Apr 28, 2008 8:59 am

ive juz got my arduino decimila + motor shield...i was juz wandering ..isit possible to power both of them and two 1.5 volt hobby dc motor with a 9v volt battery plugged in the ext plug..
besides that, i would also like know how to add in a push button on the shield that can power up everything with a push coz im actually building a rover which muz be activated that way..
i am also searching for example program codes that can program my motor to run forward for 10seconds...stop fun backwords for another 10 seconds and stop.. all actions generated after i push the button ...if anyone who could kindly post up an example..that would be helpfull

thanks for the help guys
pakun
 
Posts: 1
Joined: Mon Apr 28, 2008 8:53 am

by adafruit on Thu May 01, 2008 1:39 am

the motor control shield is for 4.5V+ dc motors or higher. i dont believe it works with 1.5V motors

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by trialex on Thu May 01, 2008 8:08 pm

I'll give you some help with the "power up everything with a push" bit.

You don't POWER everything up with a push of a button, you set it to START when you push the button.

OK so have a button connected up to a digital pin. You used a proper pull up resistor yeah?

Then you set it to do nothing in the setup function UNTIL the button is pushed, which ends the setup function, and you go into the loop function.

your code will look like this

Code: Select all | TOGGLE FULL SIZE
// Defines all you variables here

blah
blah

void setup(){

     val = digitalRead(buttonpin);

     if(val==LOW) { // Assuming you use a pull-UP resitor, use HIGH for a pull-DOWN resistor

          break;        // get out of setup()

     }   //end for if

}  // end for setup()

void loop(){

// tell your motor to run

}




This will make your program wait in the setup function, then when it reads a button push, it BREAKES out of the setup function, and starts running the main function.
trialex
 
Posts: 189
Joined: Mon Apr 03, 2006 6:25 pm

Please be positive and constructive with your questions and comments.