Picture of Obstacle-Avoiding Robot with a Personality!
Unlike most roaming 'bots, this one actually roams in such a way that it actually seems to be 'thinking'! With a BASIC Stamp microcontroller (Basic Atom, Parallax Basic Stamps, Coridium Stamp, etc.), a chassis of some kind, a few sensors, and some sophisticated code from this instructable, you can create a robot that will execute movements you never even programed into it!

Here's a video (it's kind-of low quality, but I'm working on that. (I am still trying to work out the part that it's too slow.)

Step 1: The Sensors

The (name?)...Well, let's just call it Bob. Bob has five sensors

  • Ultrasonic Rangefinder (aka "sonar")
  • 2 Sharp GP2D12 IR Sensors
  • 1 Standard IR Assembly (more on this later)
  • 1 CdS (Cadmium Sulphide) Photocell

The ultrasonic rangefinder helps Bob see obstacles that are right in front of him; they also tell him what distance the object is from him. This can be obtained from many sources. You can find them from (Parallax ; they call it the "Ping)))"), Acroname, HVW Technologies, and so many more sites. No matter where you go to find them, they all cost about the same (~ $30). The two IR sensors made by Sharp are very easy to use when used for simple object detection as in this case. You can get them at may online stores, such as the ones listed above. They help Bob see obstacles that the ultrasonic rangefinder can't; obstacles that are coming too close to the sides of the chasis. They cost about $12 to $15 depending on where you get them. The "IR assembly" I made myself; see step 2 for assembly. The CdS Photocell (or light-variable resistor, whatever your preference) is for detecting changes in ambient lighting. Bob uses them to know when he's in a dark or light room.

If anyone who has prior experience with any of the Sharp IR rangers, FYI, they are not being used for actual distance measurement in this robot. I do not have an ADC (Analog-to-Digital Converter), neither do I know how to use them that way. They are simply providing a HIGH or LOW signal to the BS2 microcontroller.

The datasheets for the Sharp IR's as well as the Ping))) sensor can be found on the net, but if you're lazy like me, you can scroll down a little further an there they are!

this looks interesting, you can find whatever u need to make your own robot here:


this looks interesting. You can find whatever you need to construct your robot here:


infanati2 years ago
Hi, I started on a project using IR sensors but for some reason my servos only keep moving forward even if the sensor detects an object ahead. I checked the code and it seems to be fine. the connections are according to the codes. so im not quite sure whats going on there. any ideas?
Here is the code if anyone sees anything wrong with it please let me know.

* Robotics with the BOE Shield - FastIrRoaming
* Adaptation of RoamingWithWhiskers with IR object detection instead of
* contact switches

#include // Include servo library

Servo servoLeft; // Declare left and right servos
Servo servoRight;

void setup() // Built-in initialization block
pinMode(10, INPUT); pinMode(9, OUTPUT); // Left IR LED & Receiver
pinMode(3, INPUT); pinMode(2, OUTPUT); // Right IR LED & Receiver

tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone

servoLeft.attach(13); // Attach left signal to pin 13
servoRight.attach(12); // Attach right signal to pin 12

void loop() // Main loop auto-repeats

int irLeft = irDetect(9, 10, 38000); // Check for object on left
int irRight = irDetect(2, 3, 38000); // Check for object on right

if((irLeft == 0) && (irRight == 0)) // If both sides detect
maneuver(-200, -200, 20); // Backward 20 milliseconds
else if(irLeft == 0) // If only left side detects
maneuver(200, -200, 20); // Right for 20 ms
else if(irRight == 0) // If only right side detects
maneuver(-200, 200, 20); // Left for 20 ms
else // Otherwise, no IR detects
maneuver(200, 200, 20); // Forward 20 ms

int irDetect(int irLedPin, int irReceiverPin, long frequency)
tone(irLedPin, frequency, 8); // IRLED 38 kHz for at least 1 ms
delay(1); // Wait 1 ms
int ir = digitalRead(irReceiverPin); // IR receiver -> ir variable
delay(1); // Down time before recheck
return ir; // Return 1 no detect, 0 detect

void maneuver(int speedLeft, int speedRight, int msTime)
// speedLeft, speedRight ranges: Backward Linear Stop Linear Forward
// -200 -100......0......100 200
servoLeft.writeMicroseconds(1500 + speedLeft); // Set left servo speed
servoRight.writeMicroseconds(1500 - speedRight); // Set right servo speed
if(msTime==-1) // if msTime = -1
servoLeft.detach(); // Stop servo signals
delay(msTime); // Delay for msTime
IR sensor to servo.png
jclaudiu2 years ago
Can i use bs2 module instead of bs2e? it works the same way ??
tzq33tdq4 years ago
do you know how much this costs? and were do i get the stuff to build it with?
This is awesome and please answer my questions.
This could, thanks to the sonar being used, theoretically be used to map places out, removing the necessity of a manual map-out of areas. This could be implemented in such things as automatic vacuums and such! The robot goes out to map the area, determines the best area covering and sets out on its mission. Coming upon an obstacle, it could update its maps, and hence never need user input!
LinemenOwn5 years ago
In step 4, what is the VDD voltage needed for the IR Detector?
RPisces (author)  LinemenOwn5 years ago
miketwo5 years ago
That's a really cute robot.  The startup chirp is the best.
omega9o6 years ago
to make it move faster remove the 100 milisec pause in the ping coding
RPisces (author)  omega9o6 years ago
...and I WOULD, except that that delay is required to wait for the ping sensor to refresh; without it, the sensor would not function properly because it is being polled too often.
airyna6 years ago
why does the source code have an error....got error on string when i run it using the Matlab
step237 years ago
hm... i want to build a robot, aswell but i dont' want to spend much money... so i guess my best bet would be to salvage parts from broken electronics... so where do i start and how much did this project cost you
RPisces (author)  step237 years ago
The whole thing cost me about $210
*Grabs chest* UGHHHHHHHHHH... *BANG*
you should try the $50 dollar robot on societyofrobots.com
try this bookmy son found it useful in making robots some out of "found" parts ....motors from broken toys parts from a mouse etc.
kenny7897 years ago
were do you get the mini bread boards they look really useful or did you jsut but the boe on the robot
RPisces (author)  kenny7897 years ago
I get those at Radioshack.
but theres no radioshack in candda :( only the crappy source witch dosent sell electonics
American Science and Surplus has a lot of parts for robot building. Just Google them. Not sure what the dollarUS/dollarCA exchange rate is any more.
Nice looking forward to build P.S fry lock is awesome
please could u tel me the range of the CdS photocell u've used...
RPisces (author) 7 years ago
**UPDATE** 'BOB V2.0' soon to come! BOB V2.0 will have hearing, extra brain power (master-slave) so he doesn't 'jerk-crawl' anymore, more stamina, sensors, and more advanced behavior! Keep your eyes open...
RPisces (author)  RPisces7 years ago
Woow. I just did the math on power consumption for the new power setup I'm using for 'BOB V2.0', and it's pretty striking. 'BOB 2.0' is going to need a switching regulator, because with 19.2V worth of rechargeables, and at least 250ma max current draw, that comes out to at least 3.55W power loss! I could have cooked an egg on that linear VR!!!
Da_Fudge7 years ago
This is absolutely awesome! Is that just a aluminium base? looks really cool! Plus from me.
RPisces (author)  Da_Fudge7 years ago
Yes, that's an all aluminum base. Thanks!
sonic555757 years ago
looks kinda like WALL-E!
Nice job, but I'm curious as to why you have it stop and go in a jerking motion?
RPisces (author)  Brandon1212337 years ago
Well, that's due to the slow microcontroller. I have the Basic Stamp loaded up with soo much code, and it is polling so many sensors and doing so much math, that it is a bit of a burden for it. The microcontroller only does like 4,000 instructions per second, where as your average AVR does like 20 MIPS! (million instructions per second). That's why I DON'T use the BS2 anymore! If I were to use the Arduino (I'm sure you've heard of it) as the 'brain' for 'Bob', then it would go REALLY fast!
Yeah my robot Walbot http://www.instructables.com/id/Make-a-wall-avoiding-Robot!/ uses the Arduino board, and it works great.
Get the ServoPal from parallax or any servo controller, then you won't have to send the pulses to the servo every 20 or so milliseconds. Then it will run smooth and not jerk.
RPisces (author)  Doug Costlow7 years ago
Yeah, but I don't believe in spending a crapload of money for some part that helps the handicap of a $50 microcontroller when I could purchase a $3 AVR chip that does three times as much as the BASIC Stamps, and is ***5,000*** times faster than the BS2 (and yes, it's that much faster)! Thanks for the info, though.
backcountry7 years ago
Here's video of an obstacle avoiding robot I made that uses no microcontroller, no programming, and only a single 9v battery. 2 distance sensors, 2 relays, 2 transistors, and a resistors/capacitors/diodes is all it takes.

Great job on this one. The speed is impressive. How about posting an instructable on it?
Brennn107 years ago
That is really great, nice job!
hay i have that thats called the boe bot right? boe bot stand for 'borad of education bot'
if you give it a suicidal oersonality does it still avoid walls or does that only affect the drop off sensors
cool! you must be really smart to make something like this, unlike me, haha.