top of page
Search
  • Writer's pictureMein-bhi-Engineer

ULTRASONIC SENSOR

Updated: Aug 6, 2022

The Ultrasonic transmitter transmits an ultrasonic wave, this wave travels in air and when it gets objected by any material it gets reflected back toward the sensor this reflected wave is observed by the Ultrasonic receiver module gets objected by any material it gets reflected back toward the sensor this reflected wave is observed by the Ultrasonic receiver module Now, to calculate the distance using the above formulae, we should know the Speed and time. Since we are using the Ultrasonic wave we know the universal speed of US wave at room conditions which is 330m/s. The circuitry inbuilt on the module will calculate the time taken for the US wave to come back and turns on the echo pin high for that same particular amount of time, this way we can also know the time taken. Now simply calculate the distance using a microcontroller or microprocessor.


HC-SR04 Sensor Features

  • Operating voltage: +5V

  • Theoretical  Measuring Distance: 2cm to 450cm

  • Practical Measuring Distance: 2cm to 80cm

  • Accuracy: 3mm

  • Measuring angle covered: <15°

  • Operating Current: <15mA

  • Operating Frequency: 40Hz


CIRCUIT DIAGRAM


CODE


int distance = 0;

long readUltrasonicDistance(int triggerPin, int echoPin)
{
  pinMode(triggerPin, OUTPUT);  // Clear the trigger
  digitalWrite(triggerPin, LOW);
  delayMicroseconds(2);
  // Sets the trigger pin to HIGH state for 10 microseconds
  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin, LOW);
  pinMode(echoPin, INPUT);
  // Reads the echo pin, and returns the sound wave travel time in microseconds
  return pulseIn(echoPin, HIGH);
}

void setup()
{
  Serial.begin(9600);

}

void loop()
{
  distance = 0.006783 * readUltrasonicDistance(6, 7);
  Serial.println(distance);
  delay(10); // Delay a little bit to improve simulation performance
}

20 views0 comments

Recent Posts

See All

Comments


bottom of page