Netduino home hardware projects downloads community

Jump to content

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

Netduino and Ping))) Ultrasonic Sensor?

  • Please log in to reply
21 replies to this topic

#21 PenZenMaster


    New Member

  • Members
  • Pip
  • 6 posts

Posted 15 January 2012 - 08:49 AM


You aren't likely to get a response very quickly to a thread that has been inactive for several months. You are better off posting a new topic.
Also if you post source code use the code tags to make it display a little bit better.

How much experience do you have with C#? You problem is is the structure of the program. I ran this in the dedugger mode and you never get to where you expect which is calling calc().

Take a look at this compared to your code and see what the differences are.

using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace test
	public class Ping
    	TristatePort cpuPort;
    	public Ping(Cpu.Pin pin)
        	cpuPort = new TristatePort(pin, false, false, ResistorModes.Disabled);

    	public int distanceToTarget()
        	cpuPort.Active = true;                      	// 1. Set CPU port to write mode
        	cpuPort.Write(true);                        	// 2. Send a pulse to the Ping))) sensor

        	cpuPort.Active = false;             			// 3. Put the port in read mode

        	bool low = false;
        	while (low == false) { low = cpuPort.Read(); }
        	long tS = System.DateTime.Now.Ticks;        	// 4. Record start time when port goes high

        	bool high = true;
        	while (high == true) { high = cpuPort.Read(); } // 5. Listen for the return pulse
        	long tE = System.DateTime.Now.Ticks;        	// 6. Record the time when the return pulse is recieved

        	int t3 = (int)(tE - tS);

        	return (t3) * 10 / 583;


    public class Program
        public static void Main()
            Ping ping = new Ping(Pins.GPIO_PIN_D2);
            while (true)


Also how do you have your hardware wired?
If it isn't autonomous, it is just an ROV.


#22 JerseyTechGuy


    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 09 January 2013 - 04:00 PM

Hi Websteria, welcome to the community.

...we're working on it. We're making sure that the login databases, etc. are integrated and we have a good set of community guidelines in place first, but we will be making available as a wiki in the hopefully near future Posted Image

In the meantime: GitHub, CodePlex, and others are great places to share...and if you need your upload limit bumped up on the forums to post more code samples just let me know...



So what ever happened with the Sandbox?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.