Friday 5 August 2016

Ultrasonic Range Meter

                                  Ultrasonic Range Meter

     
                  In this project, a Portable Ultrasonic Range Meter is designed which can be used to measure distance of a target in non-contact fashion. The project is based on Arduino, Ultrasonic Sensor and an LCD display.

Description: In this technique, a high frequency sound wave is transmitted by a transmitter and the reflected echo from a target is captured by a receiver.

As the velocity of the sound wave is known, by measuring the time of travel, the distance between the source and the target can be calculated.
Depending on the frequency of the sound wave, the SONAR can be either Infrasonic or Ultrasonic. Ultrasonic sensors produce sound waves with frequencies higher than the audible range (20Hz to 20 KHz) i.e. greater than 20 KHz. In case of an infrasonic sensor, the frequency of sound wave is less than 20Hz.

Hardware Required:

  • Arduino Uno
  • Ultrasonic Sensor HC-SR04
  • 16X2 LCD Display
  • 10KΩ POT

Circuit Diagram:


Code:


 #include <LiquidCrystal.h>
#define trigPin 10
#define echoPin 13
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
  pinMode(trigPin, OUTPUT);

  pinMode(echoPin, INPUT);

}
void loop() {
  float duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) * 0.0344;

  if (distance >= 400 || distance <= 2){
    lcd.print("Out of range");
    delay(500);
  }
  else {
    lcd.print(distance);
    lcd.print(" cm");
    delay(500);
  }
  delay(500);
  lcd.clear();
}



That's the end of this cool project session. Hope you liked it. If you think it was good, then do comment and share this post and do post your pictures if you have made them. Do not forget to comment or ask any questions if you have any doubt.And stay tuned for my next cool posts on electronics ;)
Thanks for watching :)

Bubye...take care and all the very best to all.