Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

Characteristic Locus
Inheritance object > SpstSwitch
Implements ISwitch ISensor<bool>
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Sensors.Switches
Assembly Meadow.Foundation.dll

Syntax

public class SpstSwitch : ISwitch, ISensor<bool>

Constructors

SpstSwitch(IDigitalInterruptPort)

Creates a SpstSwitch on a specified interrupt port

Declaration
public SpstSwitch(IDigitalInterruptPort interruptPort)

Parameters

Type Name Description
IDigitalInterruptPort interruptPort

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

SpstSwitch(IPin, InterruptMode, ResistorMode)

Instantiates a new SpstSwitch object connected to the specified digital pin, and with the specified CircuitTerminationType in the type parameter.

Declaration
public SpstSwitch(IPin pin, InterruptMode interruptMode, ResistorMode resistorMode)

Parameters

Type Name Description
IPin pin
InterruptMode interruptMode
ResistorMode resistorMode

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

SpstSwitch(IPin, InterruptMode, ResistorMode, TimeSpan, TimeSpan)

Instantiates a new SpstSwitch object connected to the specified digital pin, and with the specified CircuitTerminationType in the type parameter.

Declaration
public SpstSwitch(IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration, TimeSpan glitchFilterCycleCount)

Parameters

Type Name Description
IPin pin
InterruptMode interruptMode
ResistorMode resistorMode
TimeSpan debounceDuration
TimeSpan glitchFilterCycleCount

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

Properties

DigitalInputPort

Returns the DigitalInputPort.

Declaration
protected IDigitalInterruptPort DigitalInputPort { get; set; }

Property Value

Type Description
IDigitalInterruptPort

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

IsDisposed

Is the object disposed

Declaration
public bool IsDisposed { get; }

Property Value

Type Description
bool

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

IsOn

Describes whether or not the switch circuit is closed/connected (IsOn = true), or open (IsOn = false).

Declaration
public bool IsOn { get; protected set; }

Property Value

Type Description
bool

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

Methods

DigitalInChanged(object, DigitalPortResult)

Event handler when switch value has been changed

Declaration
protected void DigitalInChanged(object sender, DigitalPortResult e)

Parameters

Type Name Description
object sender
DigitalPortResult e

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

Dispose()

Represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high.

Use the SwitchCircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

Declaration
public void Dispose()

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

Dispose(bool)

Dispose of the object

Declaration
protected virtual void Dispose(bool disposing)

Parameters

Type Name Description
bool disposing

Is disposing

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

Read()

Convenience method to get the current sensor reading

Declaration
public Task<bool> Read()

Returns

Type Description
Task<bool>

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"

Events

Changed

Raised when the switch circuit is opened or closed.

Declaration
public event EventHandler Changed

Event Type

Type Description
EventHandler

Remarks

SpstSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

SpstSwitch represents a simple, on/off, Single-Pole-Single-Throw (SPST) switch that closes a circuit to either ground/common or high:

Use the CircuitTerminationType to specify whether the other side of the switch terminates to ground or high.

The following example shows how to use a SPST switch:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DigitalOutputPort _blueLED;
    SpstSwitch _spstSwitch;

    public MeadowApp()
    {
        _blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);

        _spstSwitch = new SpstSwitch(Device.Pins.D13, CircuitTerminationType.High);
        _spstSwitch.Changed += (s, e) =>
        {
            Console.WriteLine("Switch Changed");
            Console.WriteLine("Switch on: " + _spstSwitch.IsOn.ToString());
        };

        Console.WriteLine("Initial switch state, isOn: " + _spstSwitch.IsOn.ToString());
    }
}

Sample projects available on GitHub

Code Example

protected SpstSwitch spstSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    spstSwitch = new SpstSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D02, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown));
    spstSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch Changed");
        Resolver.Log.Info($"Switch on: {spstSwitch.IsOn}");
    };

    Resolver.Log.Info("SpstSwitch ready...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpstSwitch/SpstSwitch_Fritzing.svg"