HC-SR04 Ultrasonic Distance Sensor For Arduino

New product

135.00 ₹

Add to wishlist

PayU Payment Gateway
PayU Payment Gateway

More info

Please Read Below the Coding parameter.

Connect the VCC to 5V and GND to GND. Connect Trig to Pin 13 and Eco to pin 12 and run the code below.

#define trigPin 13
#define echoPin 12

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop() {
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 4) { //Do something
}
else { //Do Something

}
if (distance >= 200 || distance <= 0){
Serial.println("Out of range");
}
else {
Serial.print(distance);
Serial.println(" cm");
}
delay(500);
}



Main technical parameters:
    1: Voltage: DC5V
    2: Static current: less than 2mA
    3: Output Level: High 5V
    4: Output Level: 0V end
    5: Sensor angle: not more than 15 degrees
    6: Detection Range: 2cm-450cm
    7: Precision:  near 2mm


Other Product You Might be Interested in from My ShopHC 04NRF24L01 Wireless TR ModuleDHT11 Temperature SensorGY-521 Motion SensorHC-06 Bluetooth Module65 Set Wire for ArduinoLeonardoRGB 5MM LEDNano V3.0WIZNET W5100MEGA 2560 ADKUNO R3Mega2560 R3433Mhz TrasmitterDual H BridgeBreadBoard PowerSupplyMQ-1354Channel RelayOpening and Closing Type CurrentMQ 7

For Any Technical Assistance and Guidance Please Post on Our Forum www.sonishop.com/forum We would get back to you for same.

Reviews

Write a review

HC-SR04 Ultrasonic Distance Sensor For Arduino

HC-SR04 Ultrasonic Distance Sensor For Arduino

HC-SR04 Ultrasonic Distance Sensor For Arduino <font size="2" style="font-family:Arial;"></font><div style="font-family:Arial;background-color:rgb(255,255,255);">Please Read Below the Coding parameter.</div><div style="font-family:Arial;background-color:rgb(255,255,255);"><br /></div><div style="font-family:Arial;background-color:rgb(255,255,255);"><div><span style="font-family:arial, sans-serif;font-size:13px;">Connect the VCC to 5V and GND to GND. Connect Trig to Pin 13 and Eco to pin 12 and run the code below.</span><br style="font-family:arial, sans-serif;font-size:13px;" /><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">#define trigPin 13</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">#define echoPin 12</span><br style="font-family:arial, sans-serif;font-size:13px;" /><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">void setup() {</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">Serial.begin (9600);</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">pinMode(trigPin, OUTPUT);</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">pinMode(echoPin, INPUT);</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">}</span><br style="font-family:arial, sans-serif;font-size:13px;" /><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">void loop() {</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">long duration, distance;</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">digitalWrite(trigPin, LOW); // Added this line</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">delayMicroseconds(2); // Added this line</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">digitalWrite(trigPin, HIGH);</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">delayMicroseconds(10); // Added this line</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">digitalWrite(trigPin, LOW);</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">duration = pulseIn(echoPin, HIGH);</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">distance = (duration/2) / 29.1;</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">if (distance &lt; 4) { //Do something</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">}</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">else { //Do Something</span><br style="font-family:arial, sans-serif;font-size:13px;" /><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">}</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">if (distance &gt;= 200 || distance &lt;= 0){</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">Serial.println("Out of range");</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">}</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">else {</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">Serial.print(distance);</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">Serial.println(" cm");</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">}</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">delay(500);</span><br style="font-family:arial, sans-serif;font-size:13px;" /><span style="font-family:arial, sans-serif;font-size:13px;">}</span></div><div><br /></div></div><div style="font-family:Arial;background-color:rgb(255,255,255);"><br /></div><div style="font-family:Arial;background-color:rgb(255,255,255);"><br /></div><div style="font-family:Arial;background-color:rgb(255,255,255);">Main technical parameters:</div><div style="font-size:small;font-family:Arial;background-color:rgb(255,255,255);">    1: Voltage: DC5V</div><div style="font-size:small;font-family:Arial;background-color:rgb(255,255,255);">    2: Static current: less than 2mA</div><div style="font-size:small;font-family:Arial;background-color:rgb(255,255,255);">    3: Output Level: High 5V</div><div style="font-size:small;font-family:Arial;background-color:rgb(255,255,255);">    4: Output Level: 0V end</div><div style="font-size:small;font-family:Arial;background-color:rgb(255,255,255);">    5: Sensor angle: not more than 15 degrees</div><div style="font-size:small;font-family:Arial;background-color:rgb(255,255,255);">    6: Detection Range: 2cm-450cm</div><div style="font-size:small;font-family:Arial;background-color:rgb(255,255,255);">    7: Precision:  near 2mm</div><br /><font size="2" style="font-family:Arial;"></font><div> <a href="https://mylivechat.com/chatnoscript.aspx?HCCID=14012381" target="_blank"></a> </div><br /><font face="Courier" size="5" color="#FF9900">Other Product You Might be Interested in from My Shop</font><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151267837158"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151267837158"><font face="Arial" size="2">HC 04</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151338933715"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151338933715"><font face="Arial" size="2">NRF24L01 Wireless TR Module</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161349349860"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161349349860"><font face="Arial" size="2">DHT11 Temperature Sensor</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151340690164"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151340690164"><font face="Arial" size="2">GY-521 Motion Sensor</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151255451582"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151255451582"><font face="Arial" size="2">HC-06 Bluetooth Module</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161355667138"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161355667138"><font face="Arial" size="2">65 Set Wire for Arduino</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161353407621"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161353407621"><font face="Arial" size="2">Leonardo</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151338928077"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151338928077"><font face="Arial" size="2">RGB 5MM LED</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151246656504"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151246656504"><font face="Arial" size="2">Nano V3.0</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151236241933"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151236241933"><font face="Arial" size="2">WIZNET W5100</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161361403611"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161361403611"><font face="Arial" size="2">MEGA 2560 ADK</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151332188763"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151332188763"><font face="Arial" size="2">UNO R3</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151310479206"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151310479206"><font face="Arial" size="2">Mega2560 R3</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161351065028"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=161351065028"><font face="Arial" size="2">433Mhz Trasmitter</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151315057980"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151315057980"><font face="Arial" size="2">Dual H Bridge</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151310542835"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151310542835"><font face="Arial" size="2">BreadBoard PowerSupply</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151303354161"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151303354161"><font face="Arial" size="2">MQ-135</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151274277790"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151274277790"><font face="Arial" size="2">4Channel Relay</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151268578159"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151268578159"><font face="Arial" size="2">Opening and Closing Type Current</font></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151274282149"></a><a href="http://cgi.ebay.in/ws/eBayISAPI.dll?ViewItem&amp;item=151274282149"><font face="Arial" size="2">MQ 7</font></a><br /><a href="target="></a> <!-- VENDBASCTCTCTVENDBASCT --> <center></center><!-- VENDBASCTCTCTVENDBASCT --> <br /><font size="5">For Any Technical Assistance and Guidance Please Post on Our Forum <font color="#5566dd">www.sonishop.com/forum </font><font color="#333333">We would get back to you for same.</font></font><div><font size="5"><font color="#333333"><br /></font></font></div>
135.00 ₹

Customers who bought this product also bought:

5 other products in the same category: