Editor Version ×
Standard

1.Easy to use and quick to get started

2.The process supports design scales of 300 devices or 1000 pads

3.Supports simple circuit simulation

4.For students, teachers, creators

Profession

1.Brand new interactions and interfaces

2.Smooth support for design sizes of over 5,000 devices or 10,000 pads

3.More rigorous design constraints, more standardized processes

4.For enterprises, more professional users

Ongoing

STD UltraSonic Distance Measurement HC-SR04

License:

Mode: Editors' pick

Cloned from UltraSonic Distance Measurement HC-SR04

  • 1.3k
  • 0
  • 0
Update time: 2018-03-09 19:14:37
Creation time: 2018-03-09 19:14:37
Description
## UltraSonic Distance Measurement ## ## Small low-cost ultrasonic distance measurement modules ## Small low-cost ultrasonic distance measurement modules like this: SRF-06 are an effective way to sense the presence of nearby objects and the distance to them. Often Robots use these to sense objects or collisions and take appropriate action. Here's how these modules work: They have two transducers, basically a speaker and a microphone. Ultrasound is a high frequency sound (typically 40 KHz is used). A short burst of sound waves (often only 8 cycles) is sent out the "Transmit" transducer (left, above). Then the "Receive" transducer listens for an echo. Thus, the principle of ultrasonic distance measurement is the same as with Radio-based radar. Distance is calculated as: L = C × T/2 , where L is the length, C is the speed of sound in air, T is the time difference from the transmission from the transmitter to the receiver. This is divided by 2 for the two-directions the sound travels. Speed of sound is about: C = 344m / s (20 degrees C room temperature). Speed of sound in air velocity is affected by the air density, and for high accuracy the temperature must be taken into account, either within the module electronics (In the SRF-06 module we have) or in the Arduino software. ![UltraSonic Distance Measurement][1] The module in our example has 4 pins: Vcc Operating voltage: 5.0V Trig the transmit signal pin Echo the received echo pin Gnd Ground ![UltraSonic Distance Measurement][2] To test a module with the following Software Sketch, connect 5.0V and Ground to your Arduino, and Trig to Arduino pin 5 and Echo to Arduino pin 4. This photo shows the easy way to do this using a YourDuinoRobo1 and part of a flat cable jumper: Software will do the following: Turn the Trig pin on and off to send out a sound pulse Monitor and time how long until the Echo pin sees the echo Calculate the distance as shown above, possibly correcting for temperature Following is an example Arduino Software Sketch to show how this works. It uses a library called NewPing. This library can give you the Time, or the distance in cm or Inches. You will need to copy this to your computer, UnZip the file and copy the folder and its contents to the "libraries" folder on your computer. This is typically like: C:\Users\(yourname)\Documents\Arduino\libraries. If you're already running the Arduino development software, you will have to restart it in order for it to see the new library. Here is the Software Sketch (New Version 2.0 January 2015) you can cut and paste into a New window on your Arduino IDE:

#include "NewPing.h"
/*-----( Declare Constants and Pin Numbers )-----*/
#define  TRIGGER_PIN  5
#define  ECHO_PIN     4
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters).
                         //Maximum sensor distance is rated at 400-500cm.
/*-----( Declare objects )-----*/
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
/*-----( Declare Variables )-----*/
int DistanceIn;
int DistanceCm;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  Serial.println("UltraSonic Distance Measurement");
  Serial.println("easyeda.com  easyeda.com");
}//--(end setup )---


void loop()   
{
  delay(100);// Wait 100ms between pings (about 10 pings/sec). 29ms should be the shortest delay between pings.
  DistanceIn = sonar.ping_in();
  Serial.print("Ping: ");
  Serial.print(DistanceIn); // Convert ping time to distance and print result 
                            // (0 = outside set distance range, no ping echo)
  Serial.print(" in     ");
  
  delay(100);// Wait 100ms between pings (about 10 pings/sec). 29ms should be the shortest delay between pings.
  DistanceCm = sonar.ping_cm();
  Serial.print("Ping: ");
  Serial.print(DistanceCm); 
  Serial.println(" cm");  

}
After downloading this to your Arduino, open the Serial Monitor and you should see output like this: ![HC-SR04][3] NewPing Library:http://playground.arduino.cc/Code/NewPing#Download [1]: /editor/20151230/5683c87a711c8.JPG [2]: /editor/20151230/5683c5b8edd7a.JPG [3]: /editor/20151230/5683c7132d860.jpg
Design Drawing
schematic diagram
1 /
PCB
1 /
The preview image was not generated, please save it again in the editor.
ID Name Designator Footprint Quantity
1 HC_SR04 ULTRASONIC1 DIP 1
2 New Schematic Lib U1,U2 DIP 2
3 Arduino MEGA 2560 U3 DIP 1

Unfold

Project Attachments
Empty
Project Members
Related Projects
Change a batch
Loading...
Add to album ×

Loading...

reminder ×

Do you need to add this project to the album?

服务时间

周一至周五 9:00~18:00
  • 0755 - 2382 4495
  • 153 6159 2675

服务时间

周一至周五 9:00~18:00
  • 立创EDA微信号

    easyeda

  • QQ交流群

    664186054

  • 立创EDA公众号

    lceda-cn