Visual Studio Requirements
Windows IoT Extension for UWP extension is needed – right clicking on your project. Then, select Add > Reference..
Select Universal Windows > Exensions > Windows IoT Extension for the UWP, select the latest version and press OK
Add IO Pins Capability
(Includes adding SPI port, I2C port, etc capabilities)
To enable the IO pins open “Package.appxmanifest” > Capabilities Tab > Select “Low Level”
Namespace
using Windows.Devices.Gpio;
Using IO Pins
You can setup the IO pins in the App.xaml.cs OnLaunched() function no problem, but don’t set them up in the App() constructor
Defining your pins
//IO PINS
private GpioPin GpioPinMotorEnable;
private GpioPin GpioPinMySwitch;
Initialising
//------------------------------
//----- INITIALISE IO PINS -----
//------------------------------
var gpio = GpioController.GetDefault();
if (gpio == null)
{
//ERROR
return;
}
GpioPinMotorEnable = gpio.OpenPin(17); //<<<RPi GPIO## Pin number
GpioPinMotorEnable.Write(GpioPinValue.Low);
GpioPinMotorEnable.SetDriveMode(GpioPinDriveMode.Output);
GpioPinMySwitch = gpio.OpenPin(18); //<<<Rpi GPIO## Pin number
GpioPinMySwitch.SetDriveMode(GpioPinDriveMode.Input);
Setting Output Pins
GpioPinMotorEnable.Write(GpioPinValue.Low);
GpioPinMotorEnable.Write(GpioPinValue.High);
Reading Input Pins
if (GpioPinMySwitch.Read() == GpioPinValue.High)
{
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.