Ultrasonic HC-SR04 Distance Measuring Transducer Sensor
HC-SR04 consists of ultrasonic transmitter, receiver, and control circuit.
When trigged it sends out a series of 40KHz ultrasonic pulses and receives echo from an object.
The distance between the unit and the object is calculated by measuring the traveling time of sound and output it as the width of a TTL pulse.
power supply :5V DC
quiescent current : <2mA
effectual angle: <15°
ranging distance : 2cm – 500 cm
resolution : 0.3 cm
DownLoad Url osoyoo.com
You must be logged in to post a comment.
Test is OK.
>>HARDWARE :
Osoyoo UNO Board (Fully compatible with Arduino UNO rev.3) x 1
Breadboard x 1
HC-SR04 Ultrasonic sensor module x 1
M/M jumpers
USB Cable x 1
PC x 1
>>Pin Definitions :
VCC : 3.3V-5V ⇔ UNO 5V
GND : The Ground ⇔ UNO GND
Trig : I/O Interface of Trig ⇔ UNO PIN 8
Echo : I/O Interface of Echo ⇔ UNO PIN 7
>>Mixly source :
volatile int item;
float checkdistance_8_7() {
digitalWrite(8, LOW);
delayMicroseconds(2);
digitalWrite(8, HIGH);
delayMicroseconds(10);
digitalWrite(8, LOW);
float distance = pulseIn(7, HIGH) / 58.00;
delay(10);
return distance;
}
void setup()
{
item = 0;
pinMode(8, OUTPUT);
pinMode(7, INPUT);
Serial.begin(9600);
}
void loop()
{
item = checkdistance_8_7();
Serial.print(“Distance”);
Serial.println(item);
delay(1000);
if (item < 50) {
Serial.println("Something is very close ! ");
}
}