help how to modify this arduino sketch for a maze solver/wall follower robot

this is the sample sketch..and we want it to do the following
Go forward:

  • If sensor detects path (no wall) on the left turn left
  • else if it can drive straight then drive straight,
  • else if it can turn right then turn right.
  • else if it is at a dead end then turn around.

Welcome to the Forum. Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags which make the code looklike thiswhen posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.

If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button.

Also, you never told us what is working or not working, about the program. In other words, what is the problem?

thanks sir..the problem was that it can't solve a simple maze

the problem was that it can't solve a simple maze

And why is that? What happens?