There are numerous instructables of RCs capable of avoiding obstacles. In this project I'm trying to show a simple way, not only to avoid any kind of obstacles, but also to make the decision to take the best way out!
Instead of having a fixed ultrasonic sensor directed forward, the sensor is placed on a servo which turns from 15 to 165 degrees (where the angle of 90 degrees is supposed to be the forward direction). The sensor takes a measurement of an obstacle's distance every 6 degs (this means 25 measurements for the total angle of 150 degs) and compares with one another to find the actual angle where the distance is maximum (this happens in look_around routine).
Then the RC is supposed to turn to that direction. While are DC motors in use, it is not easy to be precise in that aim. So with some trials I found out that for a particular motor speed the RC turns 90 degs in 500 ms. So with the introduction of a simple analogy in the sketch, the RC can turn in every angle only by setting the time and direction of motors activation (lines 180 and 194 of the code).
I have also implemented in the code, the code of my older instructable (Arduino based RC with two switches - mustache like- for avoiding obstacles) for having some extra sensors on. The LED use is only meant to help realizing the part of the code that runs every second. Maybe some show off too! The routine-type architecture of my code aims to help you implementing any of the routines in your own code! I hope it does!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.