Let's Make Robots!

Multi sensor robot

Hi Guys,

ive finally got my robot platform working with simple object avoidance on a arduino, using a single ping sensor. the way i got it working was a simple if (sensor > 5cm ) drive forward; else (avoid obsticle). i now want to add some bumpers and other sensors but i cant figure out how to get it to work, and the time i felt like i was making progress i couldnt get the sketch to compile.

Is there a obvious way to set out the code so i can use multiple sensors to initiate the (avoid obsticle) loop.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I have a robot that has a Ping on a servo and I had to attach bumpers because sometimes when the wall was at an angle the Ping would not detect it. I wrote a Drive() function that had a bunch of IF statements in there, cheching the sensors, one after the other, first the left bumper, then the right bumper, then the Ping sensor. If the bumpers were hit, the robot would stop, then reverse a little, then turn the oposite way about 45 degrees to avoid the wall. If the Ping was reading a distance smaller than the treshold, the robot would stop, look left and right to determine the way to turn (towards the largest distance read), but if the Ping would read a too short distance, the robot would stop and turn around. Take a look at my robot's page, the code is attached there.

Make shure you first check the bumper states in the loop() function. After check the ping distance. If the bumpers are in Hit state make something and omit the ping behavior. If they are in Clear state go ahead with the ping behavior.