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!

Step 2: The Hardware, Brain, and Other Components

Ok. To start off, the hardware that was used for this robot was part of a kit I got. It is the "Boe-Bot" kit from Parallax (http://www.Parallax.com), but this design is very flexible; you can use any chassis you want, just be sure that 1) the ultrasonic rangefinder is at the highest elevation on the robot so it doesn't hit bottoms of railings, etc, and 2) the IR sensors are angled in such a way that they can even detect objects that are about 1" away from the robot. This keeps it from hitting edges of things that may hit the wheels.

Mounted on the chassis is Parallax's Boe-Board which came with my Boe-Bot kit, which is simply a development board that can be used with any Stamp microcontroller with the same voltage requirements and pin layout. There are many different Stamp development boards on the internet. It is $65 from Parallax.

On the dvelopment board, as Bob's brain, is the BS2e (BASIC Stamp 2 e), which is basically the same as the BS2, except with more memory (RAM and EEPROM). The EEPROM is for program storage, and the RAM is for storing the variables (temporarily, of course). Bob may not be the fastest thinker in the world (~4,000 instructions/sec), but hey, that's good enough.

Bob moves via two continuous rotation servos from Parallax which, as many servos do, have a LOT of torque. For the juice, he has a 4-cell AA battery pack (for a total of 6V) connected to the 5V regulator on the development board, which gives a steady output of, you guessed it, 5V as to not fry the components. Many devices for robotics run on either a 5V or 6V supply; for some reason, it's a standard. And you DON"T want to fry these components; they're expensive. The BS2e has an internal regulator, but don't give it more than 9V if you are not using a development board! Also, if you don't use a development board (which always have regulators), then BE SURE to use a 5V regulator.

NOTE: As for power consumption, Bob is very greedy. Use RECHARGEABLE batteries for this; they last a LOT longer. I used 4 Energizer rechargeables @ 2500ma each, which definitely prolongs the life.

Step 3: Assembling the Light Sensor Circuit

The light sensor requires a circuit for the BS2e to properly utilize it. I got this circuit right out of one of Parallax's books (actually, the one that came with my kit). NOTE: PIN 6 IS ACTUALLY PIN 1; THIS MUST MATCH THE CODE OR YOU MAY DAMAGE OTHER COMPONENTS. BE CAREFUL NOT TO MESS THAT UP.

Step 4: Assembling the Dropoff Detector

This can be put together on some bare PCB. I just ran over to RadioShack and got one, and snipped the board to fit the circuit. This part is CRUCIAL. If you mess this up, poor Bob may die. The IR detector is a Panasonic PNA4601, but you can get them from RatShack, as well as the resistors and the IR LED. It does not matter what size IR LED you get, juts make sure it's not an IR PHOTOTRANSISTOR. That is a TOTALLY different device. Also, you must use heat shrink tubing or some sort of straw (you can spray-pain it black) to narrow the beam of the IR LED, but it has to be completely sovered (except the end of the LED), or the sensor will NOT work. I used a plastic casing from Parallax. You can order the LED and the casing on their website.

Unfortunately, the frequency range on the IR detector I used was very wide, which means it is much more prone to interference. Luckily, RadioShack offers ones only tuned to 38Khz, which means Bob is less likely to act strange around remote controls and other devices that use IR. The DP2D12's are great because they are virtually interference-free because of advanced optics (the lenses) and circuitry. In future projects, I will not be using regular IR detectors. The Sharp IR's are preferable over simple IR receivers.


Step 5: Bob Needs Sound!

Connect a piezo speaker to PIN 5, and - to ground. Bob needs to express himself! The best kind of piezospeaker to use would be a surface mount one. They are almost always 5 volts. Otherwise, if you use one rated below 5V, you are going to need a resistor.

Step 6: Adding the 'Headlight'

To make Bob look cooler in the dark, he turns on a headlight when he enters a dark room. Any white LED will work for this. Since the circuit is so darn simple, I am just going to tell you: just use a 220ohm resistor to limit the current. And or course, - goes to ground.

Step 7: Fill Up Bob's Brain!

Here is the code for Bob. It is broken up into sections: declarations (constants and variables), initialization, the 'main' loop, and subroutines. The type of programming that I used is Subsumption-Based FSM (Finite State Machine) Architecture. Basically, it makes the robot run faster, and better organizes the code. If you want to venture into that relatively complex realm, read the PDF on this page. I have added comments (the text in green) to help identify different parts of the code.

All the connections to the BS2e are listed again below

  • PIN 0 - 220ohm resistor to the CdS photocell
  • PIN 5 - positive lead of piezo speaker
  • PIN 6 - SIG (signal) line of left GP2D12 (left when looking at the robot from above)
  • PIN 8 - SIG line of right GP2D12
  • PIN 9 - OUT (output) line of the IR detector (dropoff sensor)
  • PIN 10 - 1Kohm resistor to the positive lead of the IR LED
  • PIN 15 - SIG lead of ultrasonic rangefinder

Bob's code is written in such a way that

1) He, or course, avoids objects and dropoffs
2) counts the number of times each one of the sensors was triggered, and determines if he's in a spot that cannot be maneuvered in
3) generates pseudo-random numbers to randomize movement
4) turns on "headlights" after determining that he's in a dark room by using timers and IF...THEN statements

I am still working out the 'lag' part. It has to do with the discharge time of the capacitor for the light sensor, as well as an over-burdened BS2e.
<p>this looks interesting, you can find whatever u need to make your own robot here:</p><p>http://www.amazon.com/s?marketplaceID=ATVPDKIKX0DER&amp;me=A2I0DT8TRUL79X&amp;merchant=A2I0DT8TRUL79X&amp;redirect=true</p>
<p>this looks interesting. You can find whatever you need to construct your robot here:</p><p><a href="http://www.amazon.com/s?marketplaceID=ATVPDKIKX0DER&me=A2I0DT8TRUL79X&merchant=A2I0DT8TRUL79X&redirect=true" rel="nofollow">http://www.amazon.com/s?marketplaceID=ATVPDKIKX0DE...</a></p>
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? <br>Here is the code if anyone sees anything wrong with it please let me know. <br> <br>/* <br> * Robotics with the BOE Shield - FastIrRoaming <br> * Adaptation of RoamingWithWhiskers with IR object detection instead of <br> * contact switches <br> */ <br> <br>#include // Include servo library <br> <br>Servo servoLeft; // Declare left and right servos <br>Servo servoRight; <br> <br>void setup() // Built-in initialization block <br>{ <br> pinMode(10, INPUT); pinMode(9, OUTPUT); // Left IR LED &amp; Receiver <br> pinMode(3, INPUT); pinMode(2, OUTPUT); // Right IR LED &amp; Receiver <br> <br> tone(4, 3000, 1000); // Play tone for 1 second <br> delay(1000); // Delay to finish tone <br> <br> servoLeft.attach(13); // Attach left signal to pin 13 <br> servoRight.attach(12); // Attach right signal to pin 12 <br>} <br> <br>void loop() // Main loop auto-repeats <br>{ <br> <br> int irLeft = irDetect(9, 10, 38000); // Check for object on left <br> int irRight = irDetect(2, 3, 38000); // Check for object on right <br> <br> if((irLeft == 0) &amp;&amp; (irRight == 0)) // If both sides detect <br> { <br> maneuver(-200, -200, 20); // Backward 20 milliseconds <br> } <br> else if(irLeft == 0) // If only left side detects <br> { <br> maneuver(200, -200, 20); // Right for 20 ms <br> } <br> else if(irRight == 0) // If only right side detects <br> { <br> maneuver(-200, 200, 20); // Left for 20 ms <br> } <br> else // Otherwise, no IR detects <br> { <br> maneuver(200, 200, 20); // Forward 20 ms <br> } <br>} <br> <br>int irDetect(int irLedPin, int irReceiverPin, long frequency) <br>{ <br> tone(irLedPin, frequency, 8); // IRLED 38 kHz for at least 1 ms <br> delay(1); // Wait 1 ms <br> int ir = digitalRead(irReceiverPin); // IR receiver -&gt; ir variable <br> delay(1); // Down time before recheck <br> return ir; // Return 1 no detect, 0 detect <br>} <br> <br>void maneuver(int speedLeft, int speedRight, int msTime) <br>{ <br> // speedLeft, speedRight ranges: Backward Linear Stop Linear Forward <br> // -200 -100......0......100 200 <br> servoLeft.writeMicroseconds(1500 + speedLeft); // Set left servo speed <br> servoRight.writeMicroseconds(1500 - speedRight); // Set right servo speed <br> if(msTime==-1) // if msTime = -1 <br> { <br> servoLeft.detach(); // Stop servo signals <br> servoRight.detach(); <br> } <br> delay(msTime); // Delay for msTime <br>} <br>
Can i use bs2 module instead of bs2e? it works the same way ??
do you know how much this costs? and were do i get the stuff to build it with? <br>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!<br />
In step 4, what is the VDD voltage needed for the IR&nbsp;Detector? <br />
5v<br />
That's a really cute robot.&nbsp; The startup chirp is the best.<br />
to make it move faster remove the 100 milisec pause in the ping coding
...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.
why does the source code have an error....got error on string when i run it using the Matlab
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
The whole thing cost me about $210
$999,999,999,999,999,999,999,999,999,999,999,999,999,999,99?<br/>*Grabs chest* UGHHHHHHHHHH... *BANG*<br/>
you should try the $50 dollar robot on societyofrobots.com
try <a rel="nofollow" href="http://www.amazon.com/Robot-Building-Beginners-David-Cook/dp/1893115445/ref=pd_bbs_2?ie=UTF8&s=books&qid=1196876479&sr=1-2">this book</a>my son found it useful in making robots some out of &quot;found&quot; parts ....motors from broken toys parts from a mouse etc.<br/>
were do you get the mini bread boards they look really useful or did you jsut but the boe on the robot
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...
**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...
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!!!
This is absolutely awesome! Is that just a aluminium base? looks really cool! Plus from me.
Yes, that's an all aluminum base. Thanks!
looks kinda like WALL-E!
Nice job, but I'm curious as to why you have it stop and go in a jerking motion?
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 <a href="https://www.instructables.com/id/Make-a-wall-avoiding-Robot!/">https://www.instructables.com/id/Make-a-wall-avoiding-Robot!/</a> uses the Arduino board, and it works great.<br/>
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.
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.<br/>
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.<br/><a rel="nofollow" href="http://youtube.com/watch?v=zW1pwJyjOVI">http://youtube.com/watch?v=zW1pwJyjOVI</a><br/><a rel="nofollow" href="http://youtube.com/watch?v=szJ0eleTgSk">http://youtube.com/watch?v=szJ0eleTgSk</a><br/><br/>
Great job on this one. The speed is impressive. How about posting an instructable on it?
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.

About This Instructable




More by RPisces:Room Visitor Counter with Relay Control ATX Power Supply --&gt; Cheap Bench-Top Power Supply Automated Plug-In Appliances 
Add instructable to: