Program logical problem . Plz help . Thanks

I have to make a maze solving robot ! I got stuck at the left hand wall theory.
Sensor position.
Sensor1 Sensor2 Sensor3 Sensor4

void lefthandwall()
{
  M1_forward(200); // Make motor 1 run forward with 200 speed
  M2_forward(200); // Make motor 2 run forward with 200 speed
  
  if(leftoutsensor<4 && rightoutsensor <4) // If S1 S4 both sensor on black
  {
    _delay_ms(leaptime);
    readsensors();
    if ( leftoutsensor<4 || rightoutsensor<4) // If both still on black we are done
    {
      done();
    }
    if(leftoutsensor>4 && rightoutsensor>4)  // If both on white we must make a left turn
    {
      turnleft();
    }
  }
  if(leftoutsensor<4) // If S1 on black 
  {
    _delay_ms(leaptime);
    readsensors();
    if(leftoutsensor>4 && rightoutsensor>4) // If S1 and S4 on white 
    {
      turnleft();  
    }
    else
    {
      done();
    }
  }
  if( rightoutsensor<4)  // If S4 on black
  {
    _delay_ms(10);
    readsensors();
    if(leftoutsensor<4)  // If S1 on black
    {
      delay(leaptime-10);
      readsensors();
      if(rightoutsensor<4 &&leftoutsensor<4) //If both on black
      {
        done();
      }
      else
      {
        turnleft();
        return;
      }
    }
    _delay_ms(leaptime-10);
    readsensors();
    if(leftoutsensor>4 && leftcentresensor<4 && rightcentresensor<4 && rightoutsensor>4)  // After that if all on white we make a right turn
    {
      turnright();
      return;
    }
    path[pathLength]='S';
    pathLength++;
    if(path[pathLength-2]=='B'){
      shortPath();
    }
    straight();
  }
  readsensors();
  if(leftoutsensor>4 && leftcentresensor<4 && rightcentresensor<4 && rightoutsensor>4) // If all on white we turn around
  {
    turnaround();
  }
}

Please help guys :frowning:

The one you were talking about in this thread?

chasingsun360: ... now its work perfectly thanks ...

The one that works perfectly?

Problems happens

I have to make a maze solving robot ! I got stuck at the left hand wall theory.

It's not at all clear:

  • What you expect to happen
  • What actually happens

chasingsun360: Problems happens

Solutions are implemented. It's your school project. You are the one expected to diagnose and solve the problem.

It's fine to ask for help. But "Hey, doc, I need some drugs" doesn't cut it in the doctor's office, and "I'm stuck" doesn't cut it here.

Man u guys can help or not , Is not about that i try to cheat or anything , forum is for member to help each other.

If u guys feel free then help , if dont then ST*U.

"Im stuck" i am stuck , i need help . School project ? yes it is school project , but if dont let us use the internet to go into C language forum, Arduino forum , AVR forum and read others people question , post , topic , etc ??? How the heck we do it?

I didnt not ask for " hey guys can anyone do the code for me?" , did i ask that ???? I already try hard to do the code and i cant figure where im wrong at , so i need help , If next time u cant help or give a hint or give some page for ppl to read , dont post answer that not involve in anything like that .

Cheers.

"Im stuck" i am stuck , i need help .

We know that. Do you need help with your history homework? A clear problem description is necessary.

If u guys feel free then help , if dont then ST*U.

I think that all of us that might have been inclined to help should now take the newbies advice, and just move on. I certainly plan to.

I’d like to help but I’m struggling to understand the context of what this code is trying to achieve.

I’m guessing you’ve got some kind of guide line on the floor that that the robot is following and there are sensors that detect if it is still on the line…

Could you briefly just summerise the following:

How many sensors you have and where are they placed?
How does the value returned by the sensor correlate to what they are detecting?
what do the functions turnright, turnleft, turnaround, actually do?

I didn't have to wait very long (quote from other Thread)

I can't wait to see what questions arise when someone actually tries to navigate the maze.

The other Thread went on for 3 pages and 40 posts - most of it pointless - certainly had nothing to do with the Thread title.

With this opener in this Thread I suspect much the same here

I got stuck at the left hand wall theory.

@chasingsun360, if you are serious about seeking help then it is up to you to provide as MUCH data as you possibly can so we know as much about your project as you do.

It's not a game of Poker where you dare not let others see your cards.

...R

chasingsun360:
I didnt not ask for " hey guys can anyone do the code for me?" , did i ask that ???

For goodness sake, man. Stop bickering with us and tell us the blasted problem. We are up to reply #8 already and have no idea what the problem is and now you are sweaing at people who could help you.

I repeat:

It’s not at all clear:

  • What you expect to happen
  • What actually happens

Read this: How to ask good questions

Now, ask a good question, before someone complains to the moderator and the thread gets closed.

Also the thread title: "Program logical problem . Plz help . Thanks"

How to use his forum

How about a better title? Eg.

Problem with maze-solving robot when hitting left-hand wall

Then people who know something about robots, or maze-solving, are more likely to read it. "Logical problem" could mean anything.