Search code examples
uwpraspberry-pigpiowindows-10-iot-core

Cannot open (GPIO) Pin 6 in Windows 10 Iot Core


I want to let the red LED of my RainbowHAT shine. That requires that I send a high signal to the BCM 6 pin.

(Shortend) Source

Class constant:

private static readonly int GPIO_NUMBER_RED = 22;

Called in the constructor:

    var gpioController = GpioController.GetDefault();

    redPin = gpioController.OpenPin(GPIO_NUMBER_RED);
    redPin.Write(GpioPinValue.High);
    redPin.SetDriveMode(GpioPinDriveMode.Output);

I tried the values 6 (BCM), 31 (Pin number) and 22 (Wiring pin number) for my class global constant GPIO_NUMBER_RED but I get always the error:

    WinRT information: Pin ' is not available. It is reserved by the system or in use for another function.

Pin layout

https://pinout.xyz/pinout/rainbow_hat

Full source

GitHub

Package Info

    <Capabilities>
        <Capability Name="internetClient" />
        <DeviceCapability Name="lowLevel"/>
    </Capabilities>

I also restarted the Pi to "reset" maybe other application that access this Pin - without success.


Solution

  • Solution #2

    After @michaelxu-msft pointed out, that I miss used the Singelton pattern, I removed it and voila, now I can call the Init from my Constructor. I've to research why.