This rover mounts an ultrasonic distance sensor on a small servo so it can look left, right and ahead before it moves. The sensor measures how long a sound pulse takes to bounce back, and the code turns that time into a distance.
The interesting part is the decision logic. Instead of just stopping at a wall, the rover sweeps the servo, compares the distances on each side and turns toward the open space. Averaging a few readings removes most of the noise from the sensor.
A good extension is to log the distances over serial and plot them, which makes it easy to see why the rover sometimes hesitates in corners.