ULTRASONIC SENSOR INTERFACE USING ARDUINO 

 

 

📡 Ultrasonic SENSOR Interface with Arduino – Short Note

Overview:

An ultrasonic sensor is used to measure distance by using ultrasonic sound waves. It works based on “echo ranging” — it sends a sound wave and measures the time it takes to bounce back.

The most commonly used module is the HC-SR04.

Working Principle:

  • The Trigger pin sends an ultrasonic pulse (8 cycles of 40 kHz).

  • The Echo pin receives the reflected wave.

  • The time between sending and receiving is used to calculate distance:

Distance (cm)=Time (µs)×0.03432\text{Distance (cm)} = \frac{\text{Time (µs)} \times 0.0343}{2}

🔌Connection:

  • HC-SR04 PinArduino Pin
    VCC5V
    GNDGND
    TRIGDigital Pin (e.g., 9)
    ECHODigital Pin (e.g., 10)

🔌 Circuit Diagram:

 

 

📝 Sample Arduino Code:

#define TRIG_PIN 9
#define ECHO_PIN 10
#define BUZZER_PIN 8

void setup() {
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(9600);
}

void loop() {
long duration;
float distance;

// Trigger the ultrasonic pulse
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

// Measure the duration of echo
duration = pulseIn(ECHO_PIN, HIGH);

// Calculate the distance (cm)
distance = duration * 0.034 / 2;

// Display distance on Serial Monitor
Serial.print(“Distance: “);
Serial.print(distance);
Serial.println(” cm”);

// Control buzzer based on distance
if (distance < 5.0) {
digitalWrite(BUZZER_PIN, HIGH); // Buzzer ON
} else {
digitalWrite(BUZZER_PIN, LOW); // Buzzer OFF
}

delay(500);
}

🔧 Applications:

  • Obstacle detection

  • Robotic navigation

  • Smart parking systems

  • Level measurement (tank, bins)

📞 For More Details & Project Support:

 

Power Integrated Solutions
Networks | Electronics | Home Automation | Water Automation | IoT | PLC | Embedded | DBMS

📍 Location:
10A/3, Radhakrishnan Colony,
Sasthri Road, Tennur,
Tiruchirappalli, Tamil Nadu – 620017


📍 View on Google Maps

📧 Email:

📱 Phone / WhatsApp:
+91 76393 85448
+91 82488 85959

🌐 Let’s Build the Future with Innovation in Education & Technology!