Skip to main content

Meadow.Foundation.ICs.IOExpanders.Sw18AB

Sw18AB
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.ICs.IOExpanders.SerialWombat

Code Example

private Sw18AB serialWombat;
private IDigitalOutputPort digitalOutputPort;
private IDigitalInputPort digitalInputPort;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

try
{
serialWombat = new Sw18AB(Device.CreateI2cBus());
digitalOutputPort = serialWombat.CreateDigitalOutputPort(serialWombat.Pins.WP0);
digitalInputPort = serialWombat.CreateDigitalInputPort(serialWombat.Pins.WP1);
}
catch (Exception ex)
{
Resolver.Log.Error($"error: {ex.Message}");
}

return Task.CompletedTask;
}

public override async Task Run()
{
Resolver.Log.Info("Running...");

bool state = false;

while (true)
{
Resolver.Log.Info($"WP0 = {(state ? "high" : "low")}");
digitalOutputPort.State = state;
Resolver.Log.Info($"WP1 = {(digitalInputPort.State ? "high" : "low")}");
state = !state;

await Task.Delay(1000);
}
}

Sample project(s) available on GitHub

Wiring Example

To wire a Ds3502 to your Meadow board, connect the following:

Ds3502Meadow Pin
GNDGND
VCC3V3
SCLD08 (SCL Pin)
SDAD07 (SDA Pin)