Meadow.Foundation.ICs.IOExpanders.Sw18AB
| Sw18AB | |
|---|---|
| Status | |
| Source code | GitHub | 
| NuGet package | 
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:
| Ds3502 | Meadow Pin | 
|---|---|
| GND | GND | 
| VCC | 3V3 | 
| SCL | D08 (SCL Pin) | 
| SDA | D07 (SDA Pin) |