Skip to main content

Meadow.Foundation.Grove.Relays.4-ChannelSpdtRelay

4-ChannelSpdtRelay
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Grove.Relays.4-ChannelSpdtRelay

Code Example

FourChannelSpdtRelay module;

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

module = new FourChannelSpdtRelay(Device.CreateI2cBus(), 0x11);

return Task.CompletedTask;
}

public override Task Run()
{
for (int i = 0; i < 5; i++)
{
Resolver.Log.Info("All on");
module.SetAllOn();

Thread.Sleep(1000);

Resolver.Log.Info("All off");
module.SetAllOff();

Thread.Sleep(1000);

for (int j = 0; j < 4; j++)
{
Resolver.Log.Info($"{(RelayIndex)j} closed");
module.Relays[j].State = RelayState.Closed;
Thread.Sleep(1000);
}

for (int j = 0; j < 4; j++)
{
Resolver.Log.Info($"{(RelayIndex)j} open");
module.Relays[j].State = RelayState.Closed;
Thread.Sleep(1000);
}
}

return Task.CompletedTask;
}

Sample project(s) available on GitHub