please help me with this code

AFTER I BURN THIS CODE THE WHEELS MOVE FARWARD ONLY IT DOESNT TURN RIGHT OR LEFT,
S1,s2…are IR sensors.

int s1,s2,s3,s4,s5;
int ss1,ss2,ss3,ss4,ss5;
char P0_0,P0_1,P0_2,P0_3,P0_4,P0_5;
/*
P0_0 --------> Enable pin of the left half of the H-bridge
 P0_1 --------> will drive the left motor in forward direction
 P0_2 --------> will drive the left motor in reverse direction
 P0_3 --------> will drive the right motor in forward direction
 P0_4 --------> Enable pin of the right half of the H-bridge
 P0_5 --------> will drive the right motor in reverse direction
 */
void Forward()
{
  P0_1=HIGH;
  P0_2=LOW;
  P0_3=HIGH;
  P0_5=LOW;
}
/*Generally for turning we use a pulsated wave so the bOt doesnt get out of
 control i.e. we run the motor for sometime then again stop it and this is done
 very quickly to create an effective pulse. See the function below.*/
void TurnLeft()
{
  P0_1=LOW; /*Left motor is not running in any direction.*/
  P0_2=LOW;
  P0_3=HIGH; /*Right motor is running in forward direction. bOt will eventually turn left*/
  P0_5=LOW;
  delay(50); /* Wait for 50 ms*/
  P0_1=LOW;/*Motors are not running*/
  P0_2=LOW;
  P0_3=LOW;
  P0_5=LOW;
  delay(50); /*Delay of another 50 ms*/
}
/*So in the above program we have effectively created a pulse of 100ms which
 is on for 50ms and off for another 50ms. You can change this value to suit
 your needs*/
/*Similarly we can write a function to turn right*/
void TurnRight()
{
  P0_1=HIGH; /*Left motor running in forward direction.*/
  P0_2=LOW;
  P0_3=LOW; /*Right motor is not running.*/
  P0_5=LOW;
  delay(50); /*50ms time delay*/
  P0_1=LOW; /*Motors not running in any direction*/
  P0_2=LOW;
  P0_3=LOW;
  P0_5=LOW;
  delay(50); /*50ms time delay*/
}

void setup()
{ 
  Serial.begin(9600);
  ss1=analogRead(0);
  ss2=analogRead(1);
  ss3=analogRead(2);
  ss4=analogRead(3);
  ss5=analogRead(4);
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);

  pinMode(13, OUTPUT); 
  pinMode(12, OUTPUT); 
  digitalWrite(12, HIGH);

}
void loop()
{
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  delay(1000);              // wait for a second
  digitalWrite(2,P0_1);
  digitalWrite(3,P0_2);
  digitalWrite(4,P0_3);
  digitalWrite(5,P0_5);
  /*
//main loop of the program
   */
  if (ss1>996)
    s1=1;
  else
    s1=0;
  if (ss2>996)
    s2=1;
  else
    s2=0;
  if (ss3>996)
    s3=1;
  else
    s3=0;
  if (ss4>996)
    s4=1;
  else
    s4=0;
  if (ss5>996)
    s5=1;
  else
    s5=0;

  /*STEERING */
  if (s3==1)
    Forward();
  if(s2==1||s1==1)
    TurnLeft();
  else
    if(s4==1||s5==1)
      TurnRight();
  if(s1==1&&s5==1&&s3==1);
  {
    TurnRight();
  }
}

Moderator edit: [code][/code] tags added. Also reformatted. (Nick Gammon)

	P0_1=HIGH; /*Left motor running in forward direction.*/
	P0_2=LOW;
	P0_3=LOW; /*Right motor is not running.*/
	P0_5=LOW;
	delay(50); /*50ms time delay*/
	P0_1=LOW; /*Motors not running in any direction*/
	P0_2=LOW;
P0_3=LOW;
P0_5=LOW;
delay(50); /*50ms time delay*/

You're not actually writing to any hardware, so the delay does nothing except slow down the assignment of some variables.
Maybe pop in some "digitalWrite"s?

if(s1==1&&s5==1&&s3==1);

BZZZZT!

You're only reading your sensors in "setup", so their values will never be updated in loop.
This may not be what you want.

(please use code tags when posting code, and use the IDE's auto-format tool before posting code, and please DON'T SHOUT)

sorry that was my 1st post....

In case you didn’t get the hint:

if(s1==1&&s5==1&&s3==1);
{
TurnRight();
}

That semicolon is wrong.

And his spacebar looks to be broke too.

You may want to run your code through the IDE's auto-format tool.
The results may surprise you.

if((s1==1&&s2==0&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==0&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==1&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==1&&s3==1&&s4==0&&s5==0))

Could probably be expressed much more simply (and legibly) by representing the conditions as a single binary number.

  digitalWrite(13, HIGH);   // set the LED on
  // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  // wait for a second

Just wishing for it, even twice, won't make it happen.

It's funny how I don't have problems with code that a number of people here call obfuscated yet I look at that line:

if((s1==1&&s2==0&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==0&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==1&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==1&&s3==1&&s4==0&&s5==0))

and my eyes tell me to stay the hell out of it. It's one thing to ask for help finding bugs but another when it's writ into brick code. I'm viewing at 120% zoom and still I don't want to more than glance.

I totally agree with AWOL, that line needs an algorithm or something. Even just some white space!

I like the other comment but I doubt he's wishing even once. More like the comments are part of a cut and paste that wasn't understood.

Here's an idea:

bool s1 = ss1 > 996;

or even more succinctly

bool s1 = analogread (0) > 996;

That should save a few lines.

Looking at it like this

if((s1==1 && s2==0 && s3==0 && s4==0 && s5==0)
 ||(s1==1 && s2==0 && s3==0 && s4==0 && s5==0)
 ||(s1==1 && s2==1 && s3==0 && s4==0 && s5==0)
 ||(s1==1 && s2==1 && s3==1 && s4==0 && s5==0))

You can see quite easily that the first two sets of terms are the same. Whether that makes a difference, I don't know.

Hah! Beat me to it.
However, this is a real killer:

if (s1==0&&s2==0&&s3==0&&s4==0&&s5==0)
 digitalWrite(2,LOW);
 digitalWrite(3,LOW);
 digitalWrite(4,LOW);
 digitalWrite(5,LOW);

Yes. Lack of decent indenting hides that sort of thing.

dxw00d:
Looking at it like this

if((s1==1 && s2==0 && s3==0 && s4==0 && s5==0)

||(s1==1 && s2==0 && s3==0 && s4==0 && s5==0)
||(s1==1 && s2==1 && s3==0 && s4==0 && s5==0)
||(s1==1 && s2==1 && s3==1 && s4==0 && s5==0))



You can see quite easily that the first two sets of terms are the same. Whether that makes a difference, I don't know.

That's a bit better and the only difference is, does the compiler optimize the second term out or does it make larger, slower code?

It's like saying "if your number is 3 or 3 or 5 or 7 then...".
My guess is that someone missed a 0 or 1 in that second line.

if((s1==1&&s2==0&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==0&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==1&&s3==0&&s4==0&&s5==0)||(s1==1&&s2==1&&s3==1&&s4==0&&s5==0))
  • Choose better data names.
  • Indent your code properly.
  • Make the if tests more sensible.

No-one can debug this stuff.

Learn to use the IDE Auto Format Tool which requires an easy part: know where the button is,
and a harder part: have code right enough (if it compiles, AF will work) for the tool to work.