Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

J Wilson

Member Since 31 Jul 2011
Offline Last Active Jan 25 2016 08:58 PM
-----

#26346 Library for HC_SR04 Ultrasonic Rangefinder

Posted by J Wilson on 04 April 2012 - 03:08 AM

I tried my hand, a cardboard box, a piece of wood, nothing seems to put the echo pin high...

I tried to use pin D0 and D1 (+change the code of course), but that didn't help either.

Is there a way to check if this module is working, except for connecting it to the netduino?


Please forgive me. The problem is all mine. I modified the documentation and never tested it after the modification (I should know better than that).

Anyway, I had the pin documentation reversed for the constructor. Please download the updated code with the corrections. The first parameter is the pin connected to Trig. The second parameter is the pin connected to Echo. The names of the parameters are renamed to pinTrig and pinEcho (and I hope that will end all confusion).

Anyway, let me know if that does not fix your problem.


#22497 Library for HC_SR04 Ultrasonic Rangefinder

Posted by J Wilson on 06 January 2012 - 03:23 AM

Someone might find this code useful. I found these HC SR04 ultrasonic rangefinders on amazon for $15 but they had no code. I found some Arduino code, but was pretty useless for Netduino because it used blocking for the timing. So I wrote my own that uses interrupts for the timing. We used this successfully on a mobile robot for detecting obstacles. Accurate to sub-inch against hard surfaces. It is calibrated for my altitude and climate, you may need to adjust the InchConversionFactor and LatencyTicks for your environment. If you want it to read centimeters, just add your own TicksToCentimeters function. Enjoy and feel free to improve it. 2012/04/03 - Corrected pin documentation on constructor

Attached Files




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.