KY-050 Ultrasonic Distance Sensor Module with Arduino


Welcome to the world of distance sensing with the KY-050 Ultrasonic Distance Sensor module! In this guide, we’ll explore the, How to Interfacing KY-050 Ultrasonic Distance Sensor Module with Arduino. the functionality and applications of this versatile sensor. The KY-050 enables accurate distance measurement using ultrasonic waves, making it an essential component for various projects such as obstacle detection, robotics, and proximity sensing. Let’s delve into the details of the KY-050 Ultrasonic Distance Sensor and learn how to integrate it with Arduino for distance measurement applications.

Hardware Required

You will require the following Hardware Components for How to Interfacing KY-050 Ultrasonic Distance Sensor Module with Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Link
KY-050 Ultrasonic Distance Sensor1Buy Link
9v DC Adapter (Optional)1Buy Link
Jumper Wires4Buy Link
Breadboard1Buy Link

What is KY-050 Ultrasonic Distance Sensor?

The KY-050 Ultrasonic Distance Sensor is a module designed to measure distances using ultrasonic waves. It consists of an ultrasonic transducer that emits high-frequency sound pulses and a receiver that detects the reflected signals. By measuring the time taken for the sound waves to travel to an object and back, the KY-050 sensor calculates the distance to the object with high accuracy. The KY-050 module provides a reliable solution for distance sensing in Arduino projects.



  1. Operating Voltage:
    • Typically operates at 5V DC, compatible with Arduino’s voltage levels.
  2. Measurement Range:
    • Typically measures distances ranging from a few centimeters to several meters, depending on the specific model and environmental conditions.
  3. Resolution:
    • Provides high-resolution distance measurements with millimeter-level accuracy.
  4. Detection Angle:
    • Typically has a narrow detection angle, allowing precise localization of objects within the sensor’s field of view.
  5. Dimensions:
    • Compact form factor suitable for integration into robotic platforms, drones, and other electronic projects.



Pin Configuration

NoPin NameDescription
1VCCPower supply voltage input
2TrigTrigger pulse input
3EchoEcho pulse output


  1. Non-Contact Distance Sensing:
    • Enables non-contact distance measurement using ultrasonic waves, eliminating the need for physical contact with the target object.
  2. High Accuracy:
    • Provides accurate distance measurements with minimal margin of error, making it suitable for precision applications.
  3. Adjustable Sensitivity:
    • Allows for adjusting the sensitivity of the sensor to optimize performance in different environments and applications.
  4. Simple Interface:
    • Simple interface with Arduino using digital input and output pins, making it easy to integrate into Arduino projects.
  5. Low Power Consumption:
    • Designed for low power operation, minimizing energy consumption in battery-powered applications.

Circuit Diagram

The following circuit shows you the connection of the, How to Interfacing KY-050 Ultrasonic Distance Sensor Module with Arduino. Please make the connection carefully


Circuit Connections

ArduinoUltrasonic Sensor
+5VVCC Pin

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow


//For more Projects:

#define Echo_EingangsPin 7 // Echo input pin
#define Trigger_AusgangsPin 8 // Trigger output pin
// Required variables are defined
int maximumRange = 300;
int minimumRange = 2;
long distance;
long duration;
void setup () {
 pinMode (Trigger_AusgangsPin, OUTPUT);
 pinMode (Echo_EingangsPin, INPUT);
 Serial.begin (9600);
void loop () {
 // Distance measurement is started by means of the 10us long trigger signal
 digitalWrite (Trigger_AusgangsPin, HIGH);
 delayMicroseconds (10);
 digitalWrite (Trigger_AusgangsPin, LOW);
 // Now we wait at the echo input until the signal has been activated
 // and then the time measured how long it remains activated
 Duration = pulseIn (Echo_EingangsPin, HIGH);
 // Now the distance is calculated using the recorded time
 Distance = duration / 58.2;
 // Check whether the measured value is within the permissible distance
 if (distance> = maximumRange || distance <= minimumRange)
    // If not, an error message is output.
      Serial.println ("Distance outside the measuring range");
      Serial.println ("-----------------------------------");
    // The calculated distance is output in the serial output
      Serial.print ("The distance is:");
      Serial.print (distance);
      Serial.println ("cm");
      Serial.println ("-----------------------------------");
  // Pause between the individual measurements
 delay (500);


  1. Obstacle Detection: Use the KY-050 sensor for detecting obstacles and avoiding collisions in robotics and autonomous vehicle projects.
  2. Distance Measurement: Implement distance measurement systems for monitoring object distances in industrial automation and security applications.
  3. Proximity Sensing: Integrate the KY-050 sensor into proximity detection systems for detecting the presence of objects within a defined range.
  4. Liquid Level Sensing: Utilize the KY-050 sensor for measuring liquid levels in tanks and containers by detecting the distance to the liquid surface.
  5. Gesture Recognition: Incorporate the KY-050 sensor into gesture recognition systems for detecting hand movements and gestures in interactive projects.


The KY-050 Ultrasonic Distance Sensor module offers a reliable and versatile solution for distance sensing with Arduino. With its high accuracy, adjustable sensitivity, and simple interface, the KY-050 sensor provides endless possibilities for distance measurement applications in Arduino projects. Let’s explore the potential of ultrasonic distance sensing and unlock new opportunities for innovation and creativity!

Leave a Comment