You can find the source code for this sample by downloading a zip of all of our samples here and navigating to the
The sample code is available in either C++ or C#, however the documentation here only details the C# variant. Open the project in Visual Studio as follows:
Be aware that the GPIO APIs are only available on Windows 10 IoT Core, so this sample cannot run on your desktop.
You'll need a few components:
Follow this steps:
Image made with Fritzing
ARM) in the toolbar dropdown.
Universalfor Windows Authentication, then click Select.
Debugtab on the left.
When everything is set up, you should be able to press F5 (or hit the "|> Remote Machine" button) from Visual Studio. A few notes here:
The Blinky app will deploy and start on the Windows IoT device, and you should see the LED blink in sync with the simulation on the screen.
To drive the GPIO pin, first we need to initialize it. Here is the C# code:
Let's break this down a little:
GpioController.GetDefault()to get the GPIO controller.
pin, we set it to be off (High) by default using the
pinto run in output mode using the
Once we have access to the
GpioOutputPin instance, it's trivial to change the state of the pin to turn the LED on or off.
To turn the LED on, simply write the value
GpioPinValue.Low to the pin:
and of course, write `GpioPinValue.High` to turn the LED off:
Remember that we connected the other end of the LED to the 3.3 Volts power supply, so we need to drive the pin to low to have current flow into the LED.