How do I connect to HC-SR04?
Table of Contents
In this project I will introduce you to the HC-SR04 Ultrasonic sensor. It works by sending sound waves from the transmitter, which then bounce off of an object and then return to the receiver….The connections are very simple:
- VCC to 5V.
- GND to GND.
- Trig to pin 9.
- Echo to pin 10.
How connect 3 pin ultrasonic sensor to Arduino?
Interfacing ultrasonic sensors in 3 pin mode To create a 3 pin setup (GND, 5V and SIG) you have to connect both the trigger pin and the echo pin to the same digital pin on the Arduino. In the code, the only thing you have to change is line 6-7 and define the same pin for both the trigPin and the echoPin.

How does ultrasonic sensor work with Arduino?
Ultrasonic sensors work by emitting sound waves at a frequency too high for humans to hear. They then wait for the sound to be reflected back, calculating distance based on the time required. This is similar to how radar measures the time it takes a radio wave to return after hitting an object.
What is echoPin in Arduino?
This function has 2 parameters, the first one is the name of the Echo pin and for the second is the state of the pulse we are reading, either High or Low. // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); Code language: Arduino (arduino)

Is HC-SR04 waterproof?
However, using the HC-SR04 outside is a different story. It is a pretty fragile device and can easily be damaged by dirt, or even high winds. And, above all, it is not waterproof. Even sealing up its circuit board would not protect it, as the two transducers it uses are essentially just small speaker/microphones.
Does ultrasonic sensor use PWM?
Under control of a host microcontroller (trigger pulse), the ECHO(PWM) sensor emits a short 40 kHz (ultrasonic) wave. This burst travels through the air, hits an object and then bounces back to the sensor.
How to use ultrasonic sensor hc-sr04 with Arduino?
Ultrasonic Sensor HC-SR04 with Arduino Tutorial. 1 1. Arduino UNO R3 CH340 (you can use any Arduino Boards) 2 2. Ultrasonic Sensor HC-SR04. 3 3. Male to Male Jumper Wires. 4 4. Breadboard. In order to generate the ultrasound we need to set the Trigger Pin on a High State for 10 µs. That will send out an 8 cycle sonic burst 5 Steps :
What is the range of the hc-sr04?
The HC-SR04 is an inexpensive, easy to use ultrasonic distance sensor, with a range of 2 to 400 cm. It is commonly used in obstacle avoiding robots and automation projects.
What is the configuration pin of hc-sr04?
The configuration pin of HC-SR04 is VCC (1), TRIG (2), ECHO (3), and GND (4). The supply voltage of VCC is +5V and you can attach TRIG and ECHO pin to any Digital I/O in your Arduino Board. 1.
Why is my ultrasonic sensor not working on my Arduino?
The problem might be that you are using Arduino DUE, which has 3.3V pins and the ultrasonic sensors is working with 5V. Try using an resistor at the echo pin, as the 3.3V are fine for the Trig pin, but the Echo pin of the sensor will output 5V to your Arduino DUI which might damage it.