My robot with ultrasonic sensor

https://www.youtube.com/watch?v=5druVAvlyxk

Components: Arduino nano V3,Ultrasonic HC-SR04, Servo, H-Bridge, L293D, L7805. Robot program: http://maxim.wf/arduino_code/Robot_compilation.pde

Haha! Great navigation!

I love how crazy it's head spins!

   if(dist_f>=25)
   {
    a:
    motion('f',180,135,t);
    dist_135=sonar();
    front_motion(t);
    motion('f',135,90,t);  
    dist_f=sonar();
    front_motion(t);
    motion('f',90,45,t);
    dist_45=sonar();
    front_motion(t);
    motion('f',45,0,t);
    dist_r=sonar();
    front_motion(t);
    motion('f',0,45,t);
    dist_45=sonar();
    front_motion(t);
    motion('f',45,90,t);
    dist_f=sonar();
    front_motion(t);
    motion('f',90,135,t);
    dist_135=sonar();
    front_motion(t);
    motion('f',135,180,t);
    dist_l=sonar();
    front_motion(t);
    if (dist_f>=25)
    goto a;
    }

This should be a while loop, so you can loose the silly goto.

Some arrays and for loops() would greatly shorted the code.

Thanks

Is it this platform? http://www.robotshop.com/dfrobot-mobile-tank-base-1.html

Do you think you are getting good readings with panning the sonar so fast?

yes. I' measuring only several positions (0, 45, 90, 135 180). And servo waits while arduino measuring at these times