Ultrasonic Module (HCARDU0047)

Modules for various types of sensors including accelerometers. gyro's, IR motion, etc
Post Reply
admin
Site Admin
Posts: 786
Joined: Sun Aug 05, 2012 4:02 pm

Ultrasonic Module (HCARDU0047)

Post by admin » Sat Jun 20, 2020 9:28 am

Image



1.Working Voltage : 5V(DC)

2.Static current: Less than 2mA.

3.Output signal: Electric frequency signal, high level 5V, low level 0V.

4.Sensor angle: Not more than 15 degrees.

5.Detection distance: 2cm-500cm.

6.High precision: Up to 0.3cm

7.Input trigger signal: 10us TTL impulse

8.Echo signal : output TTL PWM signal



Pinout:


1.VCC

2.trig(T)

3.echo(R)

4.GND




Arduino example:


Image


  1. #define SOUNDCONSTANT 340.29
  2. #define TRIG 2
  3. #define ECHO 3
  4.  
  5. void setup()
  6. {
  7.   Serial.begin(9600);
  8.  
  9.   pinMode(TRIG, OUTPUT);
  10.   pinMode(ECHO, INPUT);
  11.   digitalWrite(TRIG, LOW);
  12. }
  13.  
  14. void loop()
  15. {
  16.   unsigned long TimeMs;
  17.   double DistanceCM;
  18.  
  19.   /* Triggers the module to send a ping */
  20.   digitalWrite(TRIG, HIGH);
  21.   digitalWrite(TRIG, LOW);
  22.  
  23.   /* Measures the time for ultrasonic burst to leave and return. */
  24.   TimeMs = pulseIn(ECHO, HIGH);
  25.  
  26.   /* Calculates the distance to an object in CMs */
  27.   DistanceCM = SOUNDCONSTANT * ((double)TimeMs / 20000);
  28.  
  29.   Serial.print("Distance to object: ");
  30.   Serial.print(DistanceCM);
  31.   Serial.println(" cm");
  32.  
  33.   delay(1000);
  34. }



Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.

Post Reply