I am using a Pi 4 board and the Grove+ to get started with IOT. I am using C#, Dotnet 5.0, System.Device.Gpio/Iot.Device.Bindings and targeting the linux-arm runtime. Everything is progressing well enough as I am able to drive the simple digital output devices such as the LED or the buzzer. However, I cannot seem to read the digital inputs correctly.
I setup the controller so:
var gpio = new GpioController();
var relay = PinValue.Low;
I2cConnectionSettings i2CConnectionSettings = new(1, GrovePi.DefaultI2cAddress);
var i2cDevice = I2cDevice.Create(i2CConnectionSettings);
var grovePi = new GrovePi(i2cDevice);
and I try to read so:
button = new Button(grovePi, GrovePort.DigitalPin6);
while (!stoppingToken.IsCancellationRequested)
{
logger.LogInformation(button.Value == PinValue.Low ? "Button is on" : "Button is off");
await Task.Delay(10000, stoppingToken);
}
What have I forgotten to do?