autonomous car

I'm doing a school project and i want to build a car that goes in a set path with object avoidance.
I want to put an IR-proximity sensors and an Ultrasonic distance sensors.With a SN754410 based dc motor driver.I can do all the circuity but I am not that good at the programming.Can anyone help me and give me a code please using these parts or any suggestions it would really help.In a later ver. I want to add an gps.

No offense, but as a school project this would be a good learning opportunity for you. If there is something that bugs me it is electrical engineers who refuse to program.

I am trying to learn but it still makes no senses to me and it has a do date,so by the time it does make senses to me it will probably be due or have one day left to program. I want to do projects for fun later when I learn to program.

Google is your friend as this is a very common project. Are you allowed to use a purchased kit?

http://www.google.com/search?q=object+avoidance+robot+site%3Ahttp%3A%2F%2Farduino.cc%2Fforum%2Findex.php&hl=en&num=100&lr=&ft=i&cr=&safe=images

http://www.google.com/search?q=object+avoidance+robot&hl=en&num=100&lr=&ft=i&cr=&safe=images

Good links and no kits.I don't want it just to randomly drive around.I want it to drive to a specific location with object avoidance, good link still helped me understand the coding better.

I don't want it just to randomly drive around.I want it to drive to a specific location with object avoidance,

Your project has several parts. You may want to work on just making the bot drive to a specific location first.

Yes,I was but then I thought to throw in the sensors.I am going to do that first tho. Then later on add more sensors to it and ultimately have i control an airplane for fun.

My school project is that of an autonomous vehicle as well, am having an issue with the timing of things if someone has some ideas, would be much appreciated.

Firstly, my hardware:

Arduino2560
SN754410 (H-Bridge)
Sharp IR GP2D120 (sensors)
Two motors with gear reduction of unknown specs. (an old RC car)

Now my issue is with the timing from the sensor (object detection) to the output of the motor. If I disable my motor when my sensor value is at a range, by the time the motor shuts off, slows down from momentum, it hits the wall.

So I used the PWM output pin to half the duty cycle, this improved things, but its still not stopping quick enough.
(at quarter, there wasn't enough power to move the vehicle, I thought about changing this mid-cycle, like a gear change, haven't tried it yet)

I thought about throwing the motor in reverse, by switching the outputs, for delay(x) then disabling, but not sure how much damage and strain this will do on the Arduino, batteries, H-Bridge.

If someone can confirm if any damage occurs to the SN754410 , or arduino whilst switching from forward to reverse immediately, would be appreciated.

If you require code, I will need to change comps, let us know.

It shouldn't strain the arduino,h brige,or motor,as many people do this to slow down there cars. Just don't hold the car in place with the motor on as electric motors have 100% of there torque when stopped an on full power witch in this case can do it if you don't have metal gearing like in more top brand cars. Hope this helps

Thanks for the fast confirmation, appreciate it!!

No need to worry about full power stall, as its only locking up with my bad tuning when it hits a wall, with the confirmation of being able to slow it down, will fix this soon.

The steering drive, has a slip gear on the reduction, so once its full left/right, nothing stalls the motor.

First I can understand your feeling so far as a student in the school. All I want to know is you don' t have the coach from the teacher.Anyway I'm still a beginner for the Arduino. I purchase board from Taobao.com in China. And I'd like to share you some of my material for you. All the following is not exactly what you really need maybe, but I positively think you can start it up and just put the ultrasonic sensor together in the Arduino.
The vehicle platform. You also can visit the link(I don't mean a adv.) hope you don't mind the chinese web page. you can build the whole picture in this project.
http://trade.taobao.com/trade/itemlist/listBoughtItems.htm?action=itemlist/QueryAction&event_submit_do_query=1&prePageNo=1&clickMore=0&pageNum=2
Attach the program code as following, please ignore the chinese comment. I manually comment in English, wish it's helpful to you.

void setup()
{
  pinMode(8,OUTPUT);//??I1??                                define I1 port
  pinMode(9,OUTPUT);//??I2??                                define I2 port 
  pinMode(10,OUTPUT);//??EA(PWM??)??                      define EA PWM
  pinMode(5,OUTPUT);//??EB(PWM??)??                       define EB PWM 
  pinMode(6,OUTPUT);//??I4??                                define I4                             
  pinMode(7,OUTPUT);//??I3??                                define I3
  pinMode(3,INPUT);//??????                               define left aviod obstacle sensor 
  pinMode(4,INPUT);//??????                               define middle aviod obstacle sensor 
  pinMode(11,INPUT);//??????                              define right aviod obstacle sensor 

}
void qianjin(int a)//??                                      go forward sub
{
     analogWrite(10,a);//???????????                analog value to set the speed
     analogWrite(5,a);                                        
     digitalWrite(7,LOW);//????????????            enable Right DC Motor clockwise rotate
     digitalWrite(6,HIGH);
     digitalWrite(8,HIGH);//????????????           enable Left DC Motor counter-clockwise rotate
     digitalWrite(9,LOW);

}
void youzhuan(int b)//??                                     Turn right
{
     analogWrite(10,b);//???????????                analog value to set the speed        
     analogWrite(5,b);
     digitalWrite(7,HIGH);//????????????           enable Right DC Motor counter-clockwise rotate
     digitalWrite(6,LOW);
     digitalWrite(8,HIGH);//????????????           enable Left DC Motor clockwise rotate
     digitalWrite(9,LOW);

}
void zuozhuan(int c)//??                                    Turn Left
{
     analogWrite(10,c);//???????????              analog value to set the speed  
     analogWrite(5,c);
     digitalWrite(7,LOW);//????????????          enable Right DC Motor clockwise rotate
     digitalWrite(6,HIGH);
     digitalWrite(8,LOW);//????????????          enable Left DC Motor clockwise rotate
     digitalWrite(9,HIGH);

}
void tingzhi()//??                                         Stop
{
     digitalWrite(7,HIGH);//??????????            enable Right DC Motor stop
     digitalWrite(6,HIGH);
     digitalWrite(8,HIGH);//??????????            enable Left DC Motor stop
     digitalWrite(9,HIGH);
}
void houtui(int d)//??                                    Go backward
{
     analogWrite(10,d);//???????????             analog value to set the speed       

     analogWrite(5,d);
     digitalWrite(7,HIGH);//????????????       enable Right DC Motor counter-clockwise rotate  
     digitalWrite(6,LOW);
     digitalWrite(8,LOW);//????????????        enable Left DC Motor clockwise rotate
     digitalWrite(9,HIGH);
}
void loop()
{
    int r,m,l;
    r=digitalRead(11);
    m=digitalRead(4);
    l=digitalRead(3);
    if(l==HIGH &&m==HIGH && r==HIGH)
    qianjin(200);
    if(l==LOW &&m==LOW  && r==LOW )
      {
        houtui(200);
        delay(300);
        youzhuan(200);
        delay(300);
      }
    if(l==LOW &&m==HIGH  && r==LOW )
      {
        houtui(200);
        delay(300);
        youzhuan(200);
        delay(300);
      }
    if(l==HIGH  &&m==LOW  && r==HIGH  )
      {
        houtui(200);
        delay(300);
        youzhuan(200);
        delay(300);
      }
    if(l==LOW &&m==LOW  && r==HIGH )
    youzhuan(200);
    if(l==LOW && m==HIGH && r==HIGH)
    youzhuan(200);
    if(l==HIGH &&m==LOW  && r==LOW )
    zuozhuan(200);
    if(l==HIGH &&m==HIGH  && r==LOW )
    zuozhuan(200);
}

RP5.jpg

continue interprete DC driver.
http://robotbase.taobao.com/search.htm?spm=11028vrd.3-1lRnb.6-2sLVzs&scid=123975700&scname=1rHB97Xnu%2FrH%2FbavsOU%3D&checkedRange=true&queryType=cat
There is another project using the ultrasonic sensor to detect thing 50cm and light up the light. ultrasonic sensor is RB URF v1.1
http://item.taobao.com/item.htm?spm=11028vrd.3-1lRnb.2328234110&id=2723263199&

int inputPin=4;  // ???????????          define the ultrasonic receive port  
int outputPin=5; // ???????????          define the ultrasonic emitting port
int ledpin=13;
void setup()
{
  Serial.begin(9600);
  pinMode(ledpin,OUTPUT);
  pinMode(inputPin, INPUT);
  pinMode(outputPin, OUTPUT);
}
void loop()

{
  digitalWrite(outputPin, LOW); // ???????????????2?s        disable ultrasonic emitting  
  delayMicroseconds(2);                                                      delay 2?s
  digitalWrite(outputPin, HIGH); // ???????????????10?s??????10?s      enable ultrasonic emitting,
  delayMicroseconds(10);                                                                      delay 10?s
  digitalWrite(outputPin, LOW);    // ??????????????                           disable ultrasonic emitting  
  int distance = pulseIn(inputPin, HIGH);  // ??????                                    read pulse 
  distance= distance/58;   // ?????????????????                              convert pulse into distance
  Serial.println(distance);   //?????                                                   serial output distance
  delay(50);   
  if (distance >=50)
  {//??????50??????                                     if distance is greater than 50cm, light the LED
     digitalWrite(ledpin,HIGH);
  }//??????50??????                                       if distance is smaller than 50cm, go out the LED
  else
     digitalWrite(ledpin,LOW);
}

untrasonic sensor.jpg