HC-SR04 Ultrasonic Distance Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects . It essentially gives your robot eyes/environmental awareness and can prevent it from crashing or falling off a table. Ultrasonic Sensor HC-SR04 has also been used in water level sensing, and even as a parking sensor.
HC-SR04 Ultrasonic Distance Sensor uses sonar to determine distance to an object like bats or dolphins do. It offers excellent range accuracy and stable readings in an easy-to-use package. Its operation is not affected by sunlight or black material like IR rangefinders are (although acoustically soft materials like cloth can be difficult to detect). Its performance is similar to the SRF005 but has a lower price.