Help please to improve this obstacle avoiding robot project.

Two classic C issues. This:

    if (i=0);{

should be:

    if (i==0){

Same thing a little further down too.