Glitch Filtering

The following sample illustrates configuring the glitch filter to 5 milliseconds.


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

namespace GlitchFilter
    public class Program
        // An output port allows you to write (send a signal) to a pin
        static OutputPort _led = new OutputPort(Pins.ONBOARD_LED, false);
        // An input port reads the signal from a pin (Should be Pins.ONBOARD_BTN, but there is a bug)
        static InputPort _button = new InputPort(Pins.ONBOARD_SW1, true, Port.ResistorMode.Disabled);

        public static void Main()
            // turn the LED off initially

            // smooth noise out over 5 milliseconds
            Cpu.GlitchFilterTime = new TimeSpan(0, 0, 0, 0, 5);

            // run forever
            while (true)
                // set the onboard LED output to be the input of the button

Netduino Samples Github Repository

Full source code for all of the samples can be found in the Netduino Samples repository on Github.

These docs are open source. If you find an issue, please file a bug, or send us a pull request. And if you want to contribute, we'd love that too!