Introduction: Distance Finder

About: I am a student of 11th grade and very interested in electronics especially Arduino. I like to share my ideas and projects to others. Please support me.

Hello Friends,

In this tutorial, I am going to show you how to interface ultra sonic sensor with Arduino to measure distance and print in serial monitor. So we need to complete 3 section. First to complete the circuit. Then we need to write the code for the project. And final section is to test the project. So let's move.

Step 1: Required Items

1. Arduino Uno

2. Ultra Sonic Sensor HC-SR04

3. Breadboard

4. Arduino Uno Cable

5. Male to Male Jumpers

So these are the items required for the projects.

Step 2: Connection

Now we need to connect the ultra sonic sensor to Arduino. So first attach the sensor to the breadboard. Then follow the connections :

  • VCC to 5V
  • GND to GND
  • Trig to D7
  • Echo to D8

After completing circuit let's move to the coding section.

Step 3: Coding

So guys let's start coding. This is the code for the project.

#define trigPin 7
#define echoPin 8

float duration;
float distance;

void setup() {

void loop() {
  duration = pulseIn(echoPin,HIGH);
  distance = (duration/2)* 0.034;
  Serial.print("Distance ");
  Serial.println(" cm");

If you want to download the code click on the download button.

After coding let's upload it to the Arduino board.

Step 4: Test the Project

Now all the work is done. The last step is to test the project and make sure whether it works or not.So guy's if you like this project please support and follow me. Thanks for reading this tutorial. And if you have any doubts please leave a comment and feel free to contact me.