Go Down

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

jada

Quote
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

chizzad

#31
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?

jada


chizzad

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)

chizzad

#34
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.

jada

WEll you did wire up things corectly
And you Were right you didnt need that ground Extra And IS it Working  ;)

chizzad

#36
Dec 14, 2010, 04:30 pm Last Edit: Dec 14, 2010, 04:48 pm by chizzad Reason: 1
still not running. im at a lost considering my code and my wiring should both work. with other code i was trying i also made the led blink to see if the code was working at all and it was. i have no idea what to do as of right now. ive changed my wiring and coding twice with no success.

EDIT: im also going to get rid of the extra ground wire along with the two black wires to the left of it in the schematic because that side doesnt need ground because im not using it.

SECOND EDIT: im going to try a few things that will most likely not work (hard to be positive right now)
1. changed to a 9v
2. also im going to try to add simple LED code to see if thats getting sent to the board and being processed.

jada

well where is your code ? abnd i just notice that your post is in the exhibition forum  ;D

chizzad

hah sorry when i first made my account i just kind of came on looked quickly and made on. if a mod wants to move it that would be great. i just now wrote up this code which the led is blinking but no motor movement.

#define m1p1 3 //motor one pin one
#define m1p2 4 //motor one pin two
const int ledPin = 13;  
void setup()
{
 pinMode (m1p1,OUTPUT);
 pinMode (m1p2,OUTPUT);
 pinMode(ledPin, OUTPUT);
 
 blink(ledPin, 20, 100);
}
void loop()
{
 digitalWrite(m1p1,HIGH);
 digitalWrite(m1p2,LOW);
   // drive motors forward set  delay
 delay(10000);
 //now drive motors reverse both
 digitalWrite(m1p1,LOW);
 digitalWrite(m1p2,HIGH);
   delay(10000);
   
}

void blink(int whatPin, int howManyTimes, int milliSecs) {
   int i = 0;
   for ( i = 0; i < howManyTimes; i++) {
     digitalWrite(whatPin, HIGH);
     delay(milliSecs/2);
     digitalWrite(whatPin, LOW);
     delay(milliSecs/2);
   }
}

jada

Hmmm well but i see you use a enable pin in your schematic i guess pin 9 You need to put it high at all time to run the motors ! ( i didnt read the entire code )

i_am_me

Hi,

I don't know if this will help you but have a look anyway :P

http://letsmakerobots.com/node/2074

Also while you're there have a look at some of the projects, there are a lot of ideas similar to yours and the community is really helpful :)

chizzad

i was planning on trying to bring in an enable pin the other day but i thought that had something to do with the switch and knowing when it was on. are you looking at the schematic that i edited with the green Xs? because it shows the switch crossed out. otherwise i dont see anything around pin 9 i will but an enablePin(HIGH) im my program a little later this morning and see how things go.

thanks again newbie for all the help.

jada

Quote
are you looking at the schematic that i edited with the green Xs?

Yeah ! dont you see a blue colour wire goint from the first pin on l293 d from the right ?  :-? :-?

chizzad

ok so once again i went a completely different way and FINALLY success. i used the full schematic and didnt eliminate the switch and altered some code up and everything is working as of now.

now its time to start the real work.

jada

Quote
FINALLY success............working as of now

:)
Quote
now its time to start the real work

this time post in the interfacing forum  ;)

Go Up