Posts: 169
Joined: Tue Mar 20, 2018 6:10 am

C# program to set I/O Pin

Tue Oct 30, 2018 8:54 am

I'm not .net programmer but I have to write code in c# programming. I want to understand basic things

How to set input and output pins in c# programming

Code: Select all

using Windows.Devices.Gpio;

public void GPIO()
    // Get the default GPIO controller on the system
    GpioController gpio = GpioController.GetDefault();
    if (gpio == null)
        return; // GPIO not available on this system

    // Open GPIO 5
    using (GpioPin pin = gpio.OpenPin(5))
        // Latch HIGH value first. This ensures a default value when the pin is set as output

        // Set the IO direction as output

    } // Close pin - will revert to its power-on state

Return to “Windows 10 for IoT”