An ultrasonic sensor is used to measure the distance to an object using sound waves. It provides measurements of the time that takes the sound to fling something and return it to the sensor.
It works on sound wave frequency like sonar. The ultrasonic sensor also cannot detect some objects.
HC-SR04 ultrasonic can measure a range of 2 cm to 400 cm (4 m).
This sensor has 2 openings on its front. One is the transmitter which transmits ultrasonic waves like a speaker and the other is a receiver that receives them like a microphone.
|Ultrasonic Pins||Arduino Pins|
|5v or Vin||5V|
Code For Ultrasonic Sensor Arduino
Ultrasonic Sensor and LCD 16x2 with Arduino
Now we are displaying the distance reading (sensor values) of the ultrasonic sensor on an LCD Display 16x2.
Pin Connections of LCD 16x2 with Arduino
|Pin No.||LCD Pins||Arduino Pins|