IRBOT started out life as a test project from the Scott Edwards book Programming and Customizing the BASIC Stamp Computer called the Whiskerbot. This was fun but I hated the whiskers. I decided to build an infra-red object detection system using the Radio Shack IR Detector and Radio Shack High Output IR LEDs. These parts were easily obtainable and not greatly expensive. For the controller of the robot I used the Parallax BASIC Stamp I.
The latest greatest version of the software, at least as of 10/9/98, gives IRBOT three modes of operation. The default mode just does object avoidance, fun in itself, but I wanted more. So I added two new modes that are based on the CDS photocells that change resistance based on light intensity. These are mounted in the front of the IRBOT and angled outward at about 30 degrees or so. The current code now has the ability to be light avoiding (photophobic) or light seeking (phototrophic). The mode is selected by triggering one or the other IR sensor for two seconds when you first turn it on. The specifics are further down this page.
If you want to build this too, my advice is get the Scott Edwards book above and a Parallax Stamp 1.4 rev. D. The rev D comes on a carrier board so no other expense is needed to get signals to and from it. The Scott Edwards book comes with programming software for the Stamp and it also comes with construction details to make the programming cable you will need to connect the Stamp to your DOS machine. The book is about $30 and the Stamp rev D is about $35. You now have a BASIC language interpreting microcontroller.
You now only need two simple integrated circuits, some resistors, some capacitors, and a way to tie them all together. All of these components may be obtained at your local Radio Shack.
![]() |
![]() |
| The IRBOT, ugly, but it works great! | ![]() |
This circuit works by modulating an IR LED at 40KHz, which is the center frequency of the Sharp GPIU5 IR Decoder module. Check what you get at Radio Shack, some GPIU modules are 38KHz, which really, is close enough anyway. When the modulated IR beam bounces off of something the IR module will react to the signal by giving a logic low on its output. The logic of this circuit functions by first allowing the microcontroller to enable the left IR LED by putting a logic low on that pin, then checking for a response. The microcontroller can then put a logic high on the left IR LED and put a logic low on the right IR LED, and looking for a response. From this sequence the microcontroller can determine if there is an object to the left, right or straight ahead, and react accordingly.
With my usual "belt and suspenders" design attitude (as was pointed out to me) I probably overdesigned my circuit. Maybe so, but the trimmed down 555 only version of this circuit didn't work very well, its been scrapped in favor of a PIC based solution (see below.)
The 2K pot in the 555 circuit is there to allow you to adjust the sensitivity of the detection circuit by moving further away from 40KHz. You may leave this out and elect to put clear cellophane tape over the face of the IR detector module instead - I haven't tried that yet. I have noted where my software looks for the response from the circuit and where it enables the left or right LED for searching. The .1uf cap on next to the 10uf cap in the upper left of the schematic is located physically close to the 555 timer. IRM is the IR detection module. If you can't get a 1.3K resistor for the 555 timer, a 3.3K and 2.2K resistor in parallel will come close enough to that value. You sometimes need to check the circuit for proper center frequency, or fiddle with it as the .1uf caps are usually +or- 20% of their posted value. Make those .1uf caps close to the 74LS00 chip and the 555 and IR module as you can.
I built my circuits by using prototyping board and point-to-point soldering of wires. This is a pain, if you know of a better way, do it. As a reference, below is a first-pass attempt at a single or double-sided PCB for this circuit. The view is from the top and you can make this a single-sided PCB by just running jumper wires between the points where the red connections go. In either case, you need to run a jumper between the two 'J' pads to connect up the response pin. Parts placement isn't very critical but make sure that the IR LEDs don't protrude further forward than the front of the IR detection module, or you will get false signals. This image will almost certainly NOT be to scale so use a copier to shrink it down so that the 8 pin IC fits onto it.

I have abandoned the discrete IR detection circuits in favor of variants of a 12C508 circuit. Using a 12C508 liberates a lot of processor time in the debouncing of the detection and noise filtering. I now have an ITU PIC programmer (less than $40) and the MPASM Micropic assember to create a microcontroller solution. I may never use discrete logic again! Even a simple PIC solution is at least as good as mine, but doesn't require my poor little Stamp I to filter out the noise, the 12C508 does that mostly with a lower parts count and complexity. It leaves more room for doing other things in the main processor and pulls less current. Its the perfect solution - and its fun to play with as well. A PIC 12C508 costs $1.80, and even if its only programmable once, its still a GREAT deal. I buy 'em by the half dozen now. I have recently finished a robust PIC solution, it is a very solid performer and I greatly enjoyed learning PIC programming and how the Sharp GPIU IR demodulators work. I have the PIC solution installed on my Bugbot, but not yet on my Irbot, as the Irbot board has my photosensors on it that I haven't moved yet.
There are a lot of connectors on this project. I used whatever I could find to make the female sides of the connectors. For the male sides (the ones on the boards) I used "header strips" clipped to the number of conductors that I needed. The Radio Shack guys will give you dumb looks if you ask for header strips, I recommend using a mail-order operation like JDR Microdevices and just order all of your electronics stuff there. The JRD part number for these header strips is HDR-40. Of course, if you have junk lying around, just use that!
The object detection circuit is only part of the IRBOT picture. You will also need to move it around. This is done by hacking two RC car servos. I used two Hitec HS303 servos for mine. If you use either Futaba or Tower Hobby servos the direction numbers will be reversed from the ones I give. In other words, reverse will be 64 not C8 and vice-versa.
Here are two explanations on hacking an RC servo, both courtesy of Marvin Green of PARTS.
My own method was different from either of these. I used a couple of Hitec HS303 servos, these are so cheap that they don't even have bushings, let alone bearings! In a nutshell, this was my process.
The reason I used a trim-pot instead of just using two resistors is so that I can tune the servo to stop when I issue a 1.5ms pulse out. To connect the servo motors you connect the red wire to +5V - +12V, the black wire to ground and the yellow/white/whatever wire to your microcontroller - in this case, a BASIC Stamp. I recommend that you use a separate battery pack for the servos than the 9V one used for the Stamp 1.4D. This will minimize problems that may be caused by the higher current draw of the servos. Also, make sure that if you do use another power source for the servos that you have all of the grounds connected together. Not the +5V, just the grounds. Some servos want that pulse to be reversed from the others, but they all want to center at 1.5ms. Plug your servos into the output ports, in this case port 0 and port 1 and run this Stamp code:
loopit:
pulsout 0,150
pulsout 1,150
pause 15
goto loopit
Now tweak the two trim pots until both motors stop moving. You have centered them on the 1.5ms timing pulse to be full stop. You have to issue pulses for at least 20ms at a time to keep the servos from getting confused. Then you can go off and do other stuff and come back to issue control pulses to the servos again.
IRBOT uses two 3" RC airplane landing tires for wheels. The foam type are lighter and thats why I used them. All servos come with a variety of servo horns. Pick the one that looks easiest to use and bolt one to each of the wheels in your favorite manner. Be careful to center them well. The back wheel is a single caster. Find one that fits under the IRBOT and doesn't get into the way.
One more component on the IRBOT is the front bump switch which is used to get IRBOT out of trouble that it didn't see (like skinny chair legs). This is simply two micro-switches glued to the front of the IRBOT with a bumper spanning them and extending out past the sides of the drive wheels. I have this switch connected to the Stamp port 2, it is sampled after the IR sensor is and has priority over all other sensor inputs. It would be nice if I could latch this pin when it changed status, but alas...
Included on the IRBOT is the ability to sense light. Two light sensors are placed such that the robot can tell if its darker to the right or the left. These take up the last two sensor ports on the Stamp 1.4D. I put them on ports 3 and 4 in my code. To get this pseudo-A/D conversion you need to place a .1uf capacitor to ground on one side of each of them and the other side goes to the input port. Try to keep the normal resistance of the CDS cell to 10K or less.
This is the I/O mapping of the pins used by the program below. Feel free to change them, but remember that you have to change the software if you do.
Note that four readings are taken when looking for an obstruction. This is a form of switch de-bounce that is done to eliminate false echoes. You may need to adjust the pot to de-tune the circuit if you find that the IRBOT is turning away from a wall that is two feet from it, the circuit is quite sensitive. Putting a layer of cellophane tape or two over the IR module may also help decrease sensitivity. To make the IR module less susceptible to outside interference, glue a patch of photographic negative over the window, this filters out most other light sources.
Speaking of eliminating false echoes. you will have to fiddle with the LED orientation to get optimal results. I have found that aiming them straight ahead is very good, but, I had to tilt them up a bit to avoid constant echoes from the floor from triggering the IR module. Experiment, and see what works best for you. The range of the sensor bounce is even greater in the dark, keep that in mind. Finally, I angled the light sensors about 30 degrees outward on either side so that I could get a wide light variance. Again, experiment to see what works for you. You will need to experiment with the values for BRIGHT and DARK in the code because your CDS cells will no doubt be different than mine.
The IRBOT has three modes that are selectable when it is turned on. To set these modes:
Again, you may have to fiddle with the trigger values that set the modes when you install your photocells, often they have vastly different sensitivities.
This is the program, its commented somewhat, and represents what happens when you hack instead of plan your code...
The prices I list here are for a version of IRbot that uses my 555 IR detection circuit above, this won't require you to learn to program PICs to get going. If you wish, just add $16 for the PARTS PIC IR detection circuit and leave out the 555/74LS04 chips, it will save you hassle and program space and give you a first class detection circuit for your bot. I recommed it, it will save you a lot of tuning hassle.
Stamp I ver. 1.4D $34.00 PC/proto board $ 4.00 (Radio Shack) Servos(cheapest found) $22.00 (Mail order via Tower_Hobbies 3" foam airplane wheels $ 6.00 (hobby store or Tower as above) very small castor wheel $ 4.00 favorite hardware store, price varies a lot. glue/misc. stuff $ ?? junk lying around, robots need a good junk box. wire/conn/switches $ 8.00 (Radio Shack)\ Sharp 38KHz IRM $ 3.60 (Radio Shack) \ You can save on this stuff if 4 or 5mm IR LEDs $ 3.40 (Radio Shack) - you buy mail order from NE555,74LS04,sockets $ 6.00 (Radio Shack) / JDR_Microdevices LEDs/caps/resistors $ 3.00 (Radio Shack)/ CDS Photocells $ 3.00 (Radio Shack)|
My next project is to make one of my robots a hunter/seeker for the local Critter Crunch (similar to Robot Sumo) competitions that occur up and down the Front Range. Its a simple logic inversion that allows a 'bot to look for and follow rather than run away from objects!