An Input-Port Object

We now know how to create an object that will connect to an output pin. We can set the state of the object and also read back the state that we have set. Next, we need to create an object to interact with an input pin connected to the switch.

InputPort switchInput =
   new InputPort(switchPin, false, Port.ResistorMode.PullUp);

The construction process for input pins is very similar to that for output pins, except that the constructor needs more information.

The first parameter identifies the pin to be used; the second specifies whether a glitch filter is to be used on this signal. A glitch filter removes stray pulses from an input signal. Such pulses can be caused by electrical noise and might make our lamp flicker on and off. The ...

Get Embedded Programming with the Microsoft® .NET Micro Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.