Meadow.Foundation.ICs.DigiPots.Mcp4162
Mcp4162 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
protected Mcp4162 mcp;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
mcp = new Mcp4162(
Device.CreateSpiBus(),
Device.Pins.D15.CreateDigitalOutputPort(),
new Resistance(5, Resistance.UnitType.Kiloohms)
);
return base.Initialize();
}
public override async Task Run()
{
Resolver.Log.Info("Run");
for (var i = 0; i <= mcp.MaxResistance.Ohms; i += 100)
{
var r = new Resistance(i, Resistance.UnitType.Ohms);
Resolver.Log.Info($"Setting resistance to {r.Ohms:0} ohms");
mcp.Rheostats[0].Resistance = r;
await Task.Delay(1000);
}
Resolver.Log.Info("Done");
}
Sample project(s) available on GitHub
Class Mcp4162
Represents an MCP4162 digital rheostat.
Assembly: Mcp4xxx.dll
View Source
Declaration
public class Mcp4162 : Mcp4xx2, ISpiPeripheral
Inheritance: System.Object
-> Meadow.Foundation.ICs.DigiPots.Mcp4xxx
Implements:
Meadow.Hardware.ISpiPeripheral
Properties
MaxSteps
Gets the maximum number of steps or resolution.
View Source
Declaration
public override int MaxSteps { get; }
Implements
Meadow.Hardware.ISpiPeripheral