Well this is one of the last parts on electronics, it’s to see the distance from “me” to an obstacle.
I’m using this infrared sensors
Short distance https://www.sparkfun.com/products/8959 (3-30cm)
Long distance https://www.sparkfun.com/products/242 (10-80cm)
This circuit is just over the arduino. and with the sensor for short distance, (and also include a barometer but this will part of others projects)
For different materials (different reflection) give us different distances, but just for a few millimeters for our case will be ok.