Program your robot to start moving forward, wait until it touches a wall, and then stop.