Help please to improve this obstacle avoiding robot project.

Made the two mods. Thanks wildbill and skullbucks. However, it still doesn´t works. The robot turns to one side or the other ramdomly.

I really don´t understand what´s not working. The code looks ok for me to do the task.

May it be a problem with the ' turnLeft = !turnLeft' statement ? I have seen that some people use ' bool turnLeft = !turnLeft ' instead. However I also tried this other way and there is no improvements.