Actually my friend coded my obstecle avoiding robot but when I uploaded it , it doesn't work so I have a confusion . IS the above code is a correct CODE FOR obstacle avoiding robot?
There is no way to answer that question without more context. What is your definition (or requirements) for an obstacle avoiding robot? For example it could be:
Robot moves in straight line and stops when obstacle is encountered.
Robot moves in straight line and turns left when obstacle is encountered.
Robot moves in straight line and turns right when obstacle is encountered.
From what distance should it detect the object?
Also, "doesn't work" needs to be defined as well. Is it not moving? Is it not detecting the object? Is it detecting the object and not responding?
@ToddL1962 , you beat me to it! I'm assuming some sort of ultrasonic sensor with a variable like EchoPin. Probably a single forward facing ultrasonic device.
@david301 can you detail your hardware. As already mentioned, what Arduino are you using? Which motor controller are you using? How have you connected all these hardware components together? What power source are you using?
Remember, we're not in the room next to you so we can't see your setup. You have to describe it to us.
Have you tested the various components of your system individually?