A small tutorial for interfacing a ultrasonic sensor with arduino this uses a sensor called HC-SR04 which sends ultrasonic waves to detect objects in front of it.
The HC-SR04 ultrasonic sensor is a very affordable distance sensor, mainly used for obstacle avoidance in various robotic projects. It is also used for water level sensing and even as a parking sensor ...