![]() ![]() For this we only need one: #include “HCSR04.h”Īfter this, we must declare all the variables and constants that we are going to use. Specifications Power Supply: DC 5V Working Current: 15mA Working Frequency: 40Hz Ranging Distance : 2cm 400cm/4m Resolution : 0. Regarding the code, the first thing to consider is the libraries that must be included. Calculated distance will be displayed on LCD display. After that, open the serial monitor at a baud rate of 9600, and put something in front of the sensor. ![]() Once your code and hardware are ready, connect Arduino to the laptop and upload the code. The Arduino then waits for an incoming pulse from the module and uses the time it took to get the distance.īut you don’t have to think about this since the library you’re going to use includes everything needed. Testing the Waterproof Ultrasonic Sensor JSN SR-04T. The HC-SR04 module needs a 10 µs pulse from the Arduino to trigger the sound wave being emitted from the module. Since the signal first traveled to the object, then back, you can get the distance to the object by dividing by 2. So by multiplying this with the time the signal took to return, you get the distance that the signal traveled. The sensor uses a microphone to detect the echo. It has also been used in turret applications, water level sensing, and even as a parking sensor. Figure-1 HC-SR04 Ultrasonic Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects. When the sound hits an object, this creates an echo that bounces back to the sensor. can use with your Arduino.Figure-1 show the working principal of ultrasonic ranging concept. The basic principle of an ultrasonic sensor is pretty basic: It sends out a sound wave from its speaker. So to follow these instructions, your board must at least be compatible with that. Power & Logic Voltage: DC 5V Current during measurment: 15mA Ultrasonic Frequency: 40 KHz Measuring Angle: 15 Trigger Input Signal: 10uS high pulse Sensor. Keep in mind that, in general, any kind of microcontroller should be able to run this type of project, but we’ll specifically be working with Arduino IDE. HCSR04 ultrasonic sensor lib by gamegine.To build this project you’ll need the following components You’ll understand this part better when I get into the workings of it later on. ![]() Secondly, the module makes the functionality of the sensor relatively simple. Firstly, connecting it is very straightforward as it only requires direct connections between the module and microcontroller. There are two things that make this type of sensor easy to use. And for those looking to get even more into the technicalities of the sensor, the GitHub repositories are open and available to all. This is especially true when talking about an Arduino, as there are a couple of very reliable libraries out there. But the fact is, it’s one of the most accessible and fun accessories for those who like to dabble in microcontrollers. Specifically, you’ll learn how to use the HC-SR04 module with an Arduino to measure the depth of a water tank.Īn ultrasonic sensor is one of those things that some people don’t like getting into just because it sounds complex to use and understand. In this tutorial, you’ll learn how to use an ultrasonic sensor. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |