Let's Make Robots! | RobotShop

Obstacle Avoidance Robot Car - Arduino

The robot moves avoiding obstacles and choosing the best way to follow by ultrasound.
IRremote.zip33.18 KB
Code_for_Obstacle_Avoidance_Arduino_Robot.txt7.38 KB

The programming code is attached here as a .txt file. Download it and paste the text on the Arduino compiler.
Remember to add the IRremote library (also attached to this post) to your arduino software before trying to compile the code! 

Further information about motor controller and IR receiver here:

I bought the robot from:

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

 Thanks for the bottom part. I got that right. But I have a problem with where to place the upper arduino related wires. Please if you've got a diagram for where to place each wire, post it. im so confused right now.

Sorry if im asking too much, but if you're an expert programmer, please help me with this:

i downloaded a script for arduino: (this is part of it)

#include "Ultrasonic.h"

#include <Servo.h>

#include <Motor.h>

Ultrasonic ultrasonic(12,13); // 12->trig, 13->echo

Servo myservo; // create servo object to control a servo

Motor motor;


it's showing me this and not letting me compile:'Ultrasonic' does not name a type

What does this mean? And what should i do to fix it?

i put the wires just like you said, downloaded the IR library and installed it, and uploaded the script. Now all that happens when I press the '1' button is the robot judt keeps moving forward. I tried to move the head thinking that the servo was stuck, but the head (the ultrasonic sensor) would just vibrate in its place. You got any idea about what's happening?


Check the wiring of the microservo and ensure that you are using the correct pin according to the programming code. 

Microservo must be connected to pin number 5.. just in case

I have bought kit, sensor shield is v4.0 , can you please help me in wiring this ? i am really confused and i am very new to this....

i have tried searching on google so far i am not able to figure it out completely. 

please i need help

You may check my wiring in the pictures i posted earlier in this blog. Look for them. Good luck!

Can you please help me in the wiring? and where should i put the ENA & ENB pins? 


i have the same robot, i have the same robot. But cannot start motors for drive the wheels.I wired the robot as in description here.

May I ask question about wiring.

1) did you connect 5V and GND contacts of motor shield to Sensor shield V5?

2) Did you connect ENA and ENB port of motor shield to sensor shield V5? In your code these ports are not declared. You dont use them? How you enable motors to start?