Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
Characteristic | Locus |
---|---|
Inheritance | object > SpdtSwitch |
Implements | ISwitch ISensor<bool> IDisposable |
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 SpdtSwitch : ISwitch, ISensor<bool>, IDisposable
Constructors
SpdtSwitch(IDigitalInterruptPort)
Creates a SpdtSwitch on a specified interrupt port
Declaration
public SpdtSwitch(IDigitalInterruptPort interruptPort)
Parameters
Type | Name | Description |
---|---|---|
IDigitalInterruptPort | interruptPort |
Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
SpdtSwitch(IPin, InterruptMode, ResistorMode)
Instantiates a new SpdtSwitch object with the center pin connected to the specified digital pin, one pin connected to common/ground and one pin connected to high/3.3V.
Declaration
public SpdtSwitch(IPin pin, InterruptMode interruptMode, ResistorMode resistorMode)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | |
InterruptMode | interruptMode | |
ResistorMode | resistorMode |
Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
SpdtSwitch(IPin, InterruptMode, ResistorMode, TimeSpan, TimeSpan)
Instantiates a new SpdtSwitch object with the center pin connected to the specified digital pin, one pin connected to common/ground and one pin connected to high/3.3V.
Declaration
public SpdtSwitch(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
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
Properties
DigitalInputPort
Returns the DigitalInputPort.
Declaration
protected IDigitalInterruptPort DigitalInputPort { get; set; }
Property Value
Type | Description |
---|---|
IDigitalInterruptPort |
Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
IsDisposed
Is the object disposed
Declaration
public bool IsDisposed { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_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
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_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
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
Dispose(bool)
Dispose of the object
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | Is disposing |
Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
Read()
Convenience method to get the current sensor reading
Declaration
public Task<bool> Read()
Returns
Type | Description |
---|---|
Task<bool> |
Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"
Events
Changed
Raised when the switch circuit is opened or closed.
Declaration
public event EventHandler Changed
Event Type
Type | Description |
---|---|
EventHandler |
Remarks
SpdtSwitch | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
SpdtSwitch represents a simple, two position, Single-Pole-Dual-Throw (SPDT) switch that closes a circuit to either ground/common or high depending on position.
The following example shows how to use a SPDT switch:
public class MeadowApp : App<F7Micro, MeadowApp>
{
DigitalOutputPort _blueLED;
SpdtSwitch _spdtSwitch;
public MeadowApp()
{
_blueLED = new DigitalOutputPort(Device.Pins.OnboardLEDBlue, true);
_spdtSwitch = new SpdtSwitch(Device.Pins.D13);
_spdtSwitch.Changed += (s, e) =>
{
Console.WriteLine("Switch Changed");
Console.WriteLine("Switch on: " + _spdtSwitch.IsOn.ToString());
};
Console.WriteLine("Initial switch state, isOn: " + _spdtSwitch.IsOn.ToString());
}
}
Sample projects available on GitHub
Code Example
protected SpdtSwitch spdtSwitch;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
spdtSwitch = new SpdtSwitch(Device.CreateDigitalInterruptPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown));
spdtSwitch.Changed += (s, e) =>
{
Resolver.Log.Info(spdtSwitch.IsOn ? "Switch is on" : "Switch is off");
};
Resolver.Log.Info("SpdtSwitch ready...");
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.SpdtSwitch/SpdtSwitch_Fritzing.svg"