PulseFeedback Example

I have tied to run this code but pulseFeedback.Trigger(); doesnt appear to exist…trying to connect a Ultrasonic Sensor to my board.

class Program {
private static GHIElectronics.TinyCLR.Devices.Signals.PulseFeedback pulseFeedback;

static void Main() {
    var distanceTriggerPin = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.
        GetDefault().OpenPin(GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.PA15);

    var distanceEchoPin = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.
        GetDefault().OpenPin(GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.PJ14);

    pulseFeedback = new GHIElectronics.TinyCLR.Devices.Signals.PulseFeedback
        (distanceTriggerPin, distanceEchoPin, GHIElectronics.TinyCLR.Devices.
        Signals.PulseFeedbackMode.DurationUntilEcho) {

        DisableInterrupts = false,
        Timeout = System.TimeSpan.FromSeconds(1),
        PulseLength = System.TimeSpan.FromTicks(100),
        EchoValue = GHIElectronics.TinyCLR.Devices.Gpio.GpioPinValue.High,
        PulseValue = GHIElectronics.TinyCLR.Devices.Gpio.GpioPinValue.High,
    };

    while (true) {
        System.Diagnostics.Debug.WriteLine(ReadDistance().ToString());
        System.Threading.Thread.Sleep(1000);
    }
}

public static double ReadDistance() {
    var time = pulseFeedback.Trigger();  //NOT SUPPORTED?
    var microseconds = time.TotalMilliseconds * 1000.0;
    var distance = microseconds * 0.036 / 2.0;

    return distance;
}

}

check the following code to see if you are missing a module…

the source code shows
[MethodImpl(MethodImplOptions.InternalCall)]
public extern TimeSpan Trigger();

Could this be that CLR1 doesn’t support Trigger()

think i worked it out…clr1 use

pulseFeedback.GeneratePulse() not Trigger()

Because you are not using TinyCLR 2.0