Moving dc motor based on two ultrasonic sensor


I have two ultrasonic sensors in front of a movable robot with dc motors fixed on it. When one sensor detects, it should check the other sensor and verify. If the other sensor detected range is too far compared to the first one, the dc motors should fire up and move towards the object. Can anyone tell me the code for this. I am new in arduino development

Hi dileep, Why do you need 2 sensors, most manage to do it with one, just detect the distance and move or turn as you wish. Take a look at my bots (under electronics), leave a message on my blog and I will get back to you with the code you need.

Hope it helps, regards.


Hey Dileep, I'm curious to know if your had any progress with your project as im attempting to do a similar thing, using the NewPing library as the basis. What have you done so far and I hope we can work together on it.