What's wrong with this codes:

The second Ping sensor on the right as the picture shown above. In order to make the Activitybot moves parallel with the wall.
while(1)
{
int n1,n2;
n1 = Right_distance();
pause(500);
n2 = Right_distance();
if(n1 > n2) // moving close to the wall
drive_speed(30,40);
if(n1 < n2) // moving away to the wall
drive_speed(40,30);
else drive_speed(30,30);
}
When the ActivityBot moves away, it can turn back, but if it moves close to the wall, it can not turn to the other side.
It's seems to simple but I can find what is wrong.

Comments
if(n1 > n2) // moving close to the wall drive_speed(30,40); else if(n1 < n2) // moving away to the wall drive_speed(40,30); else drive_speed(30,30);You can also incorporate deadband by saying things like: if(n1 > n2 + 4)....else if(n1 < n2 - 4)... else...
Please let us know if this solution had the desired effect.
Thanks, Andy
http://learn.parallax.com/propeller-c-simple-devices/sense-distance-ping
Thank you very much , the problem have been solved.
I have made two stupid mistakes, if..else..programming mistake and incorrect circuit connection .
Thank you for the update. I will mark this thread solved.
Andy