Pages: 1 2 [3]   Go Down
Author Topic: Autonomous Car  (Read 5221 times)
0 Members and 1 Guest are viewing this topic.
Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok i understand. so with a delay(10000); to make it spin for 10 seconds is that code correct?
« Last Edit: December 10, 2010, 10:54:44 am by chizzad » Logged

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

YES  smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 13, 2010, 10:59:58 am by chizzad » Logged

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

WEll you did wire up things corectly
And you Were right you didnt need that ground Extra And IS it Working  smiley-wink
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 14, 2010, 10:48:58 am by chizzad » Logged

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I don't know if this will help you but have a look anyway smiley-razz

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?  :-? :-?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
FINALLY success............working as of now
smiley
Quote
now its time to start the real work
this time post in the interfacing forum  smiley-wink
Logged

Pages: 1 2 [3]   Go Up
Jump to: