Help please to improve this obstacle avoiding robot project.

I removed the two delays in the turn subroutines. Now the robot goes forward until it finds an obstacle. But when it finds an it instead of turning right or left continuously the wheels kind of jamm in the same place.

I think the problem is that I don´t know how to change from true to false so the routinge of turning left ( or right ) keeps going until the obstacule is sorted. I have tried variations to the if statement like do-while of for-loop. None had given any good results. That´s why an example would be great to clarify concepts.

Thanks!