Go Down

Topic: Autonomous Car (Read 5 times) previous topic - next topic


const int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
const int enablePin = 9;    // H-bridge enable pin

void setup()
 pinMode(motor1Pin, OUTPUT);
 pinMode(motor2Pin, OUTPUT);
 pinMode(enablePin, OUTPUT);

  // set enablePin high so that motor can turn on: ADDED
  digitalWrite(enablePin, HIGH);
void loop()
digitalWrite(motor1Pin, HIGH);
digitalWrite(motor2Pin, LOW);

well thats not going to work if you dont have a delay because the pin is switched too fast to make any sense to the motor


Dec 10, 2010, 04:43 pm Last Edit: Dec 10, 2010, 04:54 pm by chizzad Reason: 1
ok i understand. so with a delay(10000); to make it spin for 10 seconds is that code correct?



ok great. now i know my code works. now all i have to do is trouble shoot my connections... i wish i had an idea of where to begin..

i have already went two completely different ways. the first schematic and now im currently using the second. (minus the switch)


Dec 13, 2010, 04:57 pm Last Edit: Dec 13, 2010, 04:59 pm by chizzad Reason: 1
ok guys. so since with the help of newbie and a bunch of you ive finally figured out simple code that should make my motor spin the wheels. i need to figure out why it is not. so now i am on to my wiring. im using this schematic

what is crossed out in green i didnt use and i labeled and put in what i added. also im not using a 9v im using a 4 battery pack of AA batteries.

if anyone sees anything that i messed up or a better way to go about please post or message me. thanks a lot.

Go Up