The duration variable saves the time between the emission and reception of the signal. You also create three variables of type long: duration and inches. The trigger pin is connected to digital Pin 11, and the echo pin is connected to Pin 12: int trigPin = 11 ![]() Inches = (duration/2) / 74 // Divide by 74 or multiply by 0.0135įirst, you create variables for the trigger and echo pin called trigPin and echoPin, respectively. of the ping to the reception of its echo off of an object.Ĭm = (duration/2) / 29.1 // Divide by 29.1 or multiply by 0.0343 duration is the time (in microseconds) from the sending Read the signal from the sensor: a HIGH pulse whose Give a short LOW pulse beforehand to ensure a clean HIGH pulse: The sensor is triggered by a HIGH pulse of 10 or more microseconds. ![]() * Complete Guide for Ultrasonic Sensor HC-SR04 Upload the following code to your Arduino IDE. ![]() The following table shows the connections you need to make: Ultrasonic Sensor HC-SR04
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |