Meadow.Foundation.Grove.Sensors.Switches.MagneticSwitch
MagneticSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
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
MagneticSwitch | Meadow Pin |
---|---|
GND | GND |
VCC | 3.3V |
RX | D01 |
TX | D00 |
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