Go Down

Topic: My robot with ultrasonic sensor (Read 3719 times) previous topic - next topic

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

http://maxim.wf/
http://www.youtube.com/user/FilippovM?feature=mhee

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

http://maxim.wf/
http://www.youtube.com/user/FilippovM?feature=mhee

ShockAndAwe

Haha! Great navigation!

I love how crazy it's head spins!
-New to Arduino 10/29/2012

- AustinWoehrle.net

PaulS

Code: [Select]
   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.

http://maxim.wf/
http://www.youtube.com/user/FilippovM?feature=mhee

oric_dan

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
Thanks.

http://maxim.wf/
http://www.youtube.com/user/FilippovM?feature=mhee

Go Up