PLEASE HELP!Code for obstacle avoiding robot and then course correct!

I am using a arduino UNO with L293D motor with HC-SRC04 ultrasound sensor and 2 DC motors. I need a code which could avoid a 30cms obstacle and go pass it, mean like course correct later. I have this code for reference. PLEASE ITS URGENT

#include <AFMotor.h> //import your motor shield library
#define trigPin 12 // define the pins of your sensor
#define echoPin 13 
AF_DCMotor motor1(3,MOTOR12_64KHZ); // set up motors.
AF_DCMotor motor2(4, MOTOR12_8KHZ);
void setup() {
  Serial.begin(9600); // begin serial communitication  
  Serial.println("Motor test!");
   pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves)
  pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves)
  motor1.setSpeed(255); //set the speed of the motors, between 0-255
motor2.setSpeed (255);  
void loop() {

   long duration, distance; // start the scan
  digitalWrite(trigPin, LOW);  
  delayMicroseconds(2); // delays are required for a succesful sensor operation.
  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10); //this delay is required as well!
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;// convert the distance to centimeters.;;
  if (distance < 15)/*if there's an obstacle 25 centimers, ahead, do the following: */ {   
   Serial.println ("Close Obstacle detected!" );
Serial.println ("Obstacle Details:");
Serial.print ("Distance From Robot is " );
Serial.print ( distance);
Serial.print ( " CM!");// print out the distance in centimeters.

Serial.println (" The obstacle is declared a threat due to close distance. ");
Serial.println (" Turning !");;  // Turn as long as there's an obstacle ahead. (BACKWARD);

  else {
   Serial.println ("No obstacle detected. going forward");
   delay (15);; //if there's no obstacle ahead, Go Forward!;  


If your program working?

What did you expect the program to do?

What does it do unexpected?

It's unlikely someone will write the code for you.

Previous discussions that may have info.