Skip to main content

Meadow.Foundation.Grove.Sensors.Switches.MagneticSwitch

MagneticSwitch
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Grove.Sensors.Switches.MagneticSwitch

Code Example

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

var magneticSwitch = new MagneticSwitch(Device.Pins.D13);

magneticSwitch.Changed += (s, e) =>
{
Resolver.Log.Info($"Switched - open {magneticSwitch.IsOn}");
};

return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

MagneticSwitchMeadow Pin
GNDGND
VCC3.3V
RXD01
TXD00

Class MagneticSwitch

Represents a Magnetic Switch

Assembly: MagneticSwitch.dll
View Source
Declaration
public class MagneticSwitch : ISwitch, ISensor<bool>, ISensor

Implements:
Meadow.Peripherals.Switches.ISwitch, Meadow.Peripherals.Sensors.ISensor<System.Boolean>, Meadow.Peripherals.Sensors.ISensor

Properties

IsOn

Returns the state of the switch

View Source
Declaration
public bool IsOn { get; }

Methods

Read()

Returns the state of the switch

View Source
Declaration
public Task<bool> Read()
Returns

System.Threading.Tasks.Task<System.Boolean>

Events

Changed

Event triggered when status has changed

View Source
Declaration
public event EventHandler Changed
Event Type

System.EventHandler

Implements

  • Meadow.Peripherals.Switches.ISwitch
  • Meadow.Peripherals.Sensors.ISensor<System.Boolean>
  • Meadow.Peripherals.Sensors.ISensor