Line Follower Code Problem!!!!

i make a line follower robot but i have the same condition with two or three different functions to excute
how to control that code ??
the condition of ( 1 1 1 1 1 )
i need when the sensors find this condition for the first two times do a statement and then do another statement.
:confused:

//setup loop is only defined the pins
void loop() {
  int s1 = digitalRead(9); //Sensor 1
  int s2 = digitalRead(10);//Sensor 2
  int s3 = digitalRead(11);//Sensor 3
  int s4 = digitalRead(12);//Sensor 4
  int s5 = digitalRead(13);//Sensor 5
  int s6 = digitalRead(14);//Sensor 6


  if (   (s1 == 1 && s2 = 0 && s3 == 0 && s4 == 0 && s5 == 1)
      || (s1 == 1 && s2 = 0 && s3 == 0 && s4 == 1 && s5 == 1)
      || (s1 == 1 && s2 = 1 && s3 == 0 && s4 == 1 && s5 == 1)
      || (s1 == 0 && s2 = 0 && s3 == 0 && s4 == 1 && s5 == 1)
      || (s1 == 1 && s2 = 1 && s3 == 1 && s4 == 1 && s5 == 1))  //This condition 
  {
    Straight();
  }


  if (   (s1 == 0 && s2 = 0 && s3 == 0 && s4 == 0 && s5 == 0)
      || (s1 == 0 && s2 = 0 && s3 == 1 && s4 == 0 && s5 == 1)
      || (s1 == 0 && s2 = 0 && s3 == 1 && s4 == 1 && s5 == 1)
      || (s1 == 0 && s2 = 1 && s3 == 1 && s4 == 1 && s5 == 1)
      || (s1 == 1 && s2 = 0 && s3 == 1 && s4 == 1 && s5 == 1)
      || (s1 == 1 && s2 = 1 && s3 == 1 && s4 == 1 && s5 == 0)
         (s1 == 1 && s2 = 1 && s3 == 1 && s4 == 1 && s5 == 1)) // Same condition
  {
    Left();
  }

  if (   (s1 == 0 && s2 = 0 && s3 == 1 && s4 == 0 && s5 == 0)
      || (s1 == 1 && s2 = 1 && s3 == 1 && s4 == 0 && s5 == 0))
  {
    Right();
  }

  if ((s1 == 1 && s2 = 1 && s3 == 1 && s4 == 0 && s5 == 1))
  {
    RCurve();
  }
}

void Straight()
{
  digitalWrite(2, 1);
  digitalWrite(4, 0);
  digitalWrite(6, 1);
  digitalWrite(7, 0);
}
void Right()
{
  digitalWrite(2, 1);
  digitalWrite(4, 0);
  digitalWrite(6, 0);
  digitalWrite(7, 1);
}
void Left()
{
  digitalWrite(2, 0);
  digitalWrite(4, 1);
  digitalWrite(6, 1);
  digitalWrite(7, 0);
}
void RCurve()
{
  digitalWrite(2, 1);
  digitalWrite(4, 0);
  digitalWrite(6, 0);
  digitalWrite(7, 0);
}
void LCurve()
{
  digitalWrite(2, 0);
  digitalWrite(4, 0);
  digitalWrite(6, 1);
  digitalWrite(7, 0);
}

I can't see any code! We can often help with getting code to work. But you need to post your code and describe exactly what it is intended to do and exactly what it is doing wrong. No code, no chance to help.

Steve

slipstick:
I can't see any code! We can often help with getting code to work. But you need to post your code and describe exactly what it is intended to do and exactly what it is doing wrong. No code, no chance to help.

Steve

i have modified the topic and inserted the code

You haven't really described what you want to happen. From what little you have said it sounds like you just need a global variable "count" initialised to 0 and then something like:

if (condition is 11111 and count is <2)
do first thing
count++ // add to count
else
do second thing
count=0 // set count back to zero?

I'll let you translate that to real code (or work out what it is you really mean).

Steve