Help please to improve this obstacle avoiding robot project.

One way would be to have a variable that goes from 0 to 1 in value and increments by one each time a turn decision is required. If it is 0 then it turns left, if it is 1 it runs right. If it exceeds 1 on the next increment, then it becomes 0 again and starts all over.