3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Obstacle-Avoiding Robot with a Personality!

Step 7Fill 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.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
41
Followers
10
Author:mortaldoom780(Reece)