Instructables
Picture of Arduino HC-SR04 Ultrasonic Rover

Simple Arduno Rover with HC-SR04 Ultrasonic sensor.

 
Remove these adsRemove these ads by Signing Up

Step 1:

Picture of
P1050658.JPG
P1050660.JPG

YOU will need to build this:

HC-SR04 Ultrasonic sensor

Battery holder for 6 AA batteries

6 AA batteries

Arduino UNO (I use UNO R2)
Motor Shield for Arduino (L293)

9g Servo

2 gear motors with wheels

CD box

4 male-to-male cables

4 female-to-female cables

few cable ties

I buy all components for this rover on ebay.

First you will need 2pcs Plastic Tire Wheel + DC 6V Gear Motor 48:1.

I solder 2 male-to-male cables and 104 capacitors.

I used slim CD box as a chassis, I made 2 holes on each side of CD box and then fixed gear motors with cable tie.

Step 2:

Picture of
P1050661.JPG
P1050662.JPG
P1050665.JPG

You can see all the components you need on this photo.

  1. HC-SR04 Ultrasonic sensor
  2. Battery holder for 6 AA batteries
  3. 6 AA batteries
  4. Arduino UNO (I use UNO R2)
  5. Motor Shield for Arduino (L293)

  6. 9g Servo
  7. 2 gear motors with wheels on CD box chassis.
  8. 4 male-to-male cables
  9. 4 female-to-female cables
  10. few cable ties

Step 3:

Picture of
P1050667.JPG
P1010124.JPG

Сonnection scheme is very easy.

  1. Connect 9g servo to SERVO_2 pins on motorshield
  2. Left motor to M4
  3. Right motor to M1
  4. Echo - pin A4
  5. Trig - pin A5
  6. Vcc - pin +5 ; Gnd - Gnd

I fix servo on battery box with cable tie

Step 4:

Picture of
P1010126.JPG
P1010127.JPG

Final result and video.


Faster version without servo        http://youtu.be/hBHpOV5TOY8

Step 5:

Put AFMotor.h and AFMotor.cpp to folder AFMotor in libraries folder Aduino.

gadge_s2 days ago

i want to replace arduino with pic18f4520..help me with code plzz!!

gadge_s2 days ago

i want to replace arduino with pic18f4520..help me with code plzz!!

gadge_s2 days ago

i want to replace arduino with pic18f4520..help me with code plzz!!

gadge_s2 days ago

Any way to incorporate 2 more wheels into the code? or would that just complicate things? I have two more gear boxes and wheels and would like to add them, but im not sure how the turning would work...

Hi I want to build a similar kind of Robot. But I dont ve the Arduino Shield. But I ve got the L293D IC. Can I use the above mentioned code to make my Robot work. if yes will you please help me in the Arduino-293d pin configuration. Thanks in Advance.

vishj19 days ago
I built the same project .....but this is not run proprly.....what i do ....all the connnection is same as yours
prash2828 days ago
Or give me the link 2 buy
prash2828 days ago
What type of servo you used is it continous rotation

can i use l293b???

fansblink made it!1 month ago

Cool, this realy fun... thanks for tutorial...

andy.jpg

can u help me. I cannot find A4 on the motor driver shield can u show me a daigram

you need to soldering a header to pin A0-A5 on Driver motor shield. Sorry for my bad english

pesogebra3 months ago

hi there, i have completed a line follower robot, but i want to combine with he coding of HC-SR04 for stopping the robot. i use the same adafruit motor driver L293D..kindly seeking your help..tq

vladimirkl13 months ago

function void checkPath() { .......

........... line 67 ROBOT.ino

if (curDist > curDist) {maxAngle = pos;}

//what is the condition?


Do you have the code without the servo?

excelente modelo y trabajo

Thank you for the code I tried to make something similar to this but I had trouble with the code and now it works!

mb6410 months ago

hello I cannot download your code I get an error

Eagle199393 (author)  mb6410 months ago

here is ROBOT.ino

ok thanks

E3D3 Eagle19939310 months ago

Thanks

To bad it don't work here. One motor refuses to work ?!

E3D311 months ago

Annoying that the code is in rtf-format, plain Chinese would have been nicer.

moek0011 months ago

I try to make this, but I cannot upload the codes. some errors are coming... ? how can I add NewPing.h libry? if I an using L298N H bridge for motors, instead of motor shield how the codes should change ?

gholam1 year ago
gooooooooood
b101011 year ago

Hi, Nice robot. did you have any problems with spiking results from the ultrasonics?

I rotate mine at 15 degree intervals reading in both directions. giving me 7 values 15 degrees apart. But I get two things happen, odd spikes and swapping values, for eg:

4 5 8 15 17 21 9

3 5 7 35 18 21 8

4 4 7 14 16 3 9

4 6 9 34 17 22 7

Notice the center values swapping without the bot moving 15 35 14 34 ??

Also 2nd last column 21 21 3 22 Where did the 3 come from.

The code is simple, I have been a code cutter for years so I am no stranger to debugging.

Only this one has the better off me so far.

Any ideas

Cheers

biomech751 year ago

Nice Job!!! 2 Things:

  1. You can use a 9V battery pack (less weight, less space)
  2. If the code wont compile even with the NewPing code you need to install the Adafruit motor shield library Link: http://learn.adafruit.com/adafruit-motor-shield/library-install
Eagle199393 (author)  biomech751 year ago

L293 drivers, 2 motors, servo consumes too much power for 9v battery. Using 9v batteries is waste of money. Only rechageable 9V are good, but I dont have one.

epaybot1 year ago

got an error with the code

MoonDocker1 year ago

I checked the code it will not compile :(

Eagle199393 (author)  MoonDocker1 year ago

Ок, I uploaded correct version of the code. It works. Try it.

Okay looks good it compiles okay. I will let you know how it turns out. I am waiting for another HC-SR04. You might want to mention they will need to install the NewPing library. You can find it here --> http://forum.arduino.cc/index.php?topic=106043.0

Thanks for sharing !

cudy7891 year ago
Do you happen to have the code to control the robot?
Eagle199393 (author)  cudy7891 year ago
(removed by author or community request)

Cool, Thanks!

I have made similar one earlier. Watch it at

www.youtube.com/watch?v=Nh31PzSrANo

If anybody want code of it, mail me at mahesh_jo@hotmail.com

mahesh_jo1 year ago

I have made similar one earlier. Watch it at

www.youtube.com/watch?v=Nh31PzSrANo

If anybody want code of it, mail me at mahesh_jo@hotmail.com


My dogs would love this, then Eat it.. Sadly..

M4rc3lv1 year ago

What did you put on the bottom of the CD Box as a third wheel? Or does it work without a third wheel?

Eagle199393 (author)  M4rc3lv1 year ago

I glued small plastic ball, which was cut to make a platform for glue.

Watch also faster version without servo

youtu.be/hBHpOV5TOY8?t=2m50s