Loading... Please wait...

HC-SR04 Ultrasonic Sensor Distance Measuring Module

Hover over image to zoom

  • Image 1
Varies
$3.75
SKU:
CIC-0000004
Weight:
0.10 Ounces
Shipping:
Calculated at checkout
Gift Wrapping:
Options available

Sorry but this item is currently unavailable. Please check back at a later stage.

 Product Description


Ultrasonic Module HC-SR04 Distance Measuring Sensor for Arduino

Highly cost-effective ultrasonic distance-measuring sensor that uses active sonar technology to determine distance.

Specifications

  • Power Supply : 5V DC

  • Quiescent Current :

  • Effective Angle:

  • Ranging Distance : 2cm – 450 cm ~(1" - 17ft)

  • Resolution : 0.3 cm  ~(1/10" in) up to 2.5m

Pinout
  • Vcc
  • Trig
  • Echo
  • GND

Library

Available here: HRC-SR04 library

 

 Product Videos

Arduino Ultrasonic Distance Measurin
  • Arduino Ultrasonic Distance Measurin
    Music: Kalima, Mr Scruff. This video may have content that is ...

 Product Documents


#define ECHOPIN 2                            // Pin to receive echo pulse

#define TRIGPIN 3                            // Pin to send trigger pulse



int counter = 0;

void setup(){

  Serial.begin(9600);

  pinMode(ECHOPIN, INPUT);

  pinMode(TRIGPIN, OUTPUT);

}



void loop(){

  double cumulativeDistance = 0;

  double averagedDistance = 0;

  double lowDistance = 0;

  double highDistance = 0;

  int i;

  int measurementsPerSec = 2;

  

  for (i = 0; i < measurementsPerSec; i++){

    digitalWrite(TRIGPIN, LOW);                   // Set the trigger pin to low for 2uS

    delayMicroseconds(2);

    digitalWrite(TRIGPIN, HIGH);                  // Send a 10uS high to trigger ranging

    delayMicroseconds(10);

    digitalWrite(TRIGPIN, LOW);                   // Send pin low again

    double duration = pulseIn(ECHOPIN, HIGH)/2; // Read in times pulse (microsecs)

    //const float speedOfSound = 343.2;     // in m/s

    //const float speedOfSound = 1126;      // in ft/s

    //const double speedOfSound = 34320;    // in cm/s

    const float speedOfSound = 13512;       // in in/s

    double distance = (duration/1000000) * speedOfSound;

    if (i == 0){

      lowDistance = distance;

      highDistance = distance;

    }

    if (distance < lowDistance)

      lowDistance = distance;

    if (distance > highDistance)

      highDistance = distance;

    cumulativeDistance += distance;

    averagedDistance = cumulativeDistance/(i+1);

    Serial.print("Averaged distance = ");

    Serial.println(averagedDistance);

    Serial.print("current distance measurement = ");

    Serial.println(distance);                     

    delay(1000/measurementsPerSec); // Wait before next ranging

  }

  Serial.print("Averaged value over 1 second = ");

  averagedDistance = cumulativeDistance/i;

  Serial.println(averagedDistance);

  Serial.print("Low distance = ");

  Serial.println(lowDistance);

  Serial.print("High distance = ");

  Serial.println(highDistance);

 }  



 Find Similar Products by Category

You Recently Viewed...

 

What's News

newsletter

Copyright 2017 oddWires. All Rights Reserved.
 Sitemap | oddWires

Click the button below to add the HC-SR04 Ultrasonic Sensor Distance Measuring Module to your wish list.