Meadow.Foundation.ICs.ADC.Ads7128
Ads7128 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
private Ads7128 adc;
private IAnalogInputPort ch0;
public override async Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
adc = new Ads7128(
bus,
Ads7128.Addresses.Default);
ch0 = adc.CreateAnalogInputPort(adc.Pins.AIN0);
}
public override async Task Run()
{
while (true)
{
var voltage = await ch0.Read();
Resolver.Log.Info($"AIN0 voltage: {voltage.Volts:N2}");
await Task.Delay(2000);
}
}