Remarks

Sw18AB
Status Status badge: working
Source code GitHub
NuGet package NuGet 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:

Ds3502 Meadow Pin
GND GND
VCC 3V3
SCL D08 (SCL Pin)
SDA D07 (SDA Pin)
Characteristic Locus
Inheritance object SerialWombatBase > Sw18AB
Implements IDigitalInputOutputController IDigitalInputController IDigitalOutputController IPwmOutputController IAnalogInputController IPinController II2cPeripheral
Inherited Members SerialWombatBase.DefaultI2cAddress SerialWombatBase.I2cAddress SerialWombatBase.SyncRoot SerialWombatBase.Logger SerialWombatBase.Pins SerialWombatBase.SendPacket(Span<byte>, Span<byte>) SerialWombatBase.Version SerialWombatBase.Info SerialWombatBase.Uuid SerialWombatBase.SendCommand(in Span<byte>) SerialWombatBase.ReadPublicData(SerialWombatBase.SwPin) SerialWombatBase.ReadPublicData(IPin) SerialWombatBase.ReadPublicData(byte) SerialWombatBase.WritePublicData(SerialWombatBase.SwPin, ushort) SerialWombatBase.WritePublicData(byte, ushort) SerialWombatBase.ReadFlash(SerialWombatBase.FlashRegister18) SerialWombatBase.ReadFlash(uint) SerialWombatBase.ConfigureOutputPin(byte, bool, OutputType) SerialWombatBase.ConfigureInputPin(byte, ResistorMode) SerialWombatBase.ConfigurePwm(byte, float, bool) SerialWombatBase.ConfigurePwmDutyCycle(byte, float) SerialWombatBase.ConfigurePwm(byte, Frequency) SerialWombatBase.ConfigurePwm(byte, uint) SerialWombatBase.ConfigureAnalogInput(byte, ushort, ushort) SerialWombatBase.ConfigureUltrasonicSensor(IPin, IPin, bool) SerialWombatBase.ReadUltrasonicSensorPulses(IPin) SerialWombatBase.ManualTriggerUltrasonicSensor(IPin) SerialWombatBase.GetSupplyVoltage() SerialWombatBase.GetTemperature() SerialWombatBase.CreateDigitalOutputPort(IPin, bool, OutputType) SerialWombatBase.CreateDigitalInputPort(IPin, ResistorMode) SerialWombatBase.CreateDigitalInputPort(IPin) SerialWombatBase.CreatePwmPort(IPin, Frequency, float, bool) SerialWombatBase.CreateAnalogInputPort(IPin, int) SerialWombatBase.CreateAnalogInputPort(IPin, int, TimeSpan, Voltage) SerialWombatBase.CreateAnalogInputArray(params IPin[]) SerialWombatBase.CreateDistanceSensor(IPin, IPin) SerialWombatBase.CreateDistanceSensor(IPin, IPin, TimeSpan) SerialWombatBase.CreateServo(IPin) object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.ICs.IOExpanders
Assembly SerialWombat.dll

Syntax

public class Sw18AB : SerialWombatBase, IDigitalInputOutputController, IDigitalInputController, IDigitalOutputController, IPwmOutputController, IAnalogInputController, IPinController, II2cPeripheral

Constructors

Sw18AB(II2cBus, Addresses, Logger?)

Creates a new Serial Wombat object

Declaration
public Sw18AB(II2cBus i2cBus, SerialWombatBase.Addresses address = Addresses.Address_0x6b, Logger? logger = null)

Parameters

Type Name Description
II2cBus i2cBus

The I2C bus connected to the wombat

SerialWombatBase.Addresses address

The I2C address

Logger logger

Meadow logger (optional)

Remarks

Sw18AB
Status Status badge: working
Source code GitHub
NuGet package NuGet 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:

Ds3502 Meadow Pin
GND GND
VCC 3V3
SCL D08 (SCL Pin)
SDA D07 (SDA Pin)