This is my Hello World project for the world of micro controllers. After searching around I settle on an obstacle avoiding bot. This project is still very early in it’s life cycle - I guess it’s in the prototype phase.
The treads, gear box and mounting platforms are from Tamiya. For TinyCLR.com, I’m using the Domino, Component Shield (because I really don’t want to solder too much at this point) and DC Motor Driver board.
From my sensors, I am using 2 Sharp infrared GP2Y0A21 (range is 10 to 80 cm). I will be adding another facing front, as it sometimes will run into objects.
My battery pack for the time being is from a broken cordless drill’s pack that cracked. It’s putting out about 9v. I’m using motors purchased from Pololu.com that can the handle extra voltage over 6v.
I’ve uploaded the project code, including my simple logging app. In the Program.cs file you’ll see some of the code that I tried and abandoned, but kept in the code for reference.
My concept was to have, on start up, an array that defines the motor speed for a given detected distance. The array for the speed on the high end starts off at 100 and gets to 0 at index 40 (as defined by SpeedArrayMin). The value then goes into the negative values. This way, for obstacle further away it would make smaller adjustments, and then conversely, the closer the object the greater the turn.
In the main loop that I get the readings from the Sharps (using MarkH’s library) and then act upon the values. After I get a reading, I set the opposite side’s motor to the speed from the array. This will cause the bot to turn away from the detected obstacle.
The exception is if it gets a close reading (currently defined as 30 cm as the constant ReverseLimiter) on both sensors. Then it employs a different set of logic - it will come to a stop, back up and turn away.