Pages: [1]   Go Down
Author Topic: My robot with ultrasonic sensor  (Read 3282 times)
0 Members and 1 Guest are viewing this topic.
Moscow, Russia
Offline Offline
Newbie
*
Karma: 4
Posts: 28
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Moscow, Russia
Offline Offline
Newbie
*
Karma: 4
Posts: 28
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Seattle, Washington
Offline Offline
Newbie
*
Karma: 0
Posts: 2
- AustinWoehrle.net
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Haha! Great navigation!

I love how crazy it's head spins!
Logged

-New to Arduino 10/29/2012

- AustinWoehrle.net

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
   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.

Logged

Moscow, Russia
Offline Offline
Newbie
*
Karma: 4
Posts: 28
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks
Logged


the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Moscow, Russia
Offline Offline
Newbie
*
Karma: 4
Posts: 28
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Pages: [1]   Go Up
Jump to: