Making a distance comparison

I need to follow a center road to its end, then turn either left or right depending on which path is longer. I am not able to find a process to compare the values I get after I use the ultrasonic sensor to check each path. (The length of the two paths are not constant.) Do I need another type of sensor? If not, how do I write the software to first do the comparison, and then make the decision about which path to follow?

If I understand correctly, you have a robot rover with an ultrasonic sensor (such as this one) that’s trying to do some sort of maze solving, correct?

So you already have your robot moving down the center of the path, and when you get to a “T” junction you want to decide if you want to go left or right. I would recommend turning the robot so that is faces left and make a series of ultrasonic range measurements, and then turning right to make a second series of measurements and then compare the results.

Depending on the environmental conditions of your project, you might need to do some signal processing to both sets of measurements in order to reliably get the right range measurement. My first approach would be to try average all of the readings of the series, and maybe also record the maximum range measured for each distance.

Does this help with your problem, or is it something else that’s causing problems? If you could post more details about your robot, such as the parts used, and a few pictures, that would help a lot.

Best regards,