Introduction: How to Turn a Led on Raspberry Pi 2 With Windows 10 IoT
Hi folks!
Today I'm going to show you how to use Visual Studio 2015 using Windows 10 IoT.
Make sure you have setup your sd card with Windows 10 IoT.
If you didn't already, here is a brief guide from Microsoft
This is a draft, I will complete this instructable asap! In the
meanwhile, write down if you have suggestions or you would like me to cover a particular topic.
Step 1: Start a New Project on Visual Studio 2015 Community Edition
On Visual Studio, start a new project selecting Universal Windows Apps.
Step 2: Add a Windows 10 IoT Reference in Your Project
From the menu bar Project -> Add references -> Windows 10 IoT Extensions
If you don't see it, you must install Windows 10 IoT Project templates from this website
After this, you could be prompted to enable developer mode on windows 10 iot to allow you to test your applications
Step 3: Setup the Circuit
Tools you will need:
1. Breadboard
2. Red Led 5mm
3. 220 ohm resistor
4. two wires
Connect the circuit to the gpio interface as shown
Step 4: Writing the Code
In the file app.xaml.cs, let's write this code.
Let's comment it!
using Windows.Devices.Gpio; //add this reference
public sealed partial class MainPage : Page {
private const int LED_PIN = 5; // let's define that in this case our pin is n°5
private void InitGPIO() { // create this procedure
var gpio = GpioController.GetDefault(); // we initialize the gpio controller
var pin = gpio.OpenPin(LED_PIN); // initialize pin
var pinValue = GpioPinValue.High; //define an high state => 5volts
pin.Write(pinValue); // we enable the output
pin.SetDriveMode(GpioPinDriveMode.Output); //configuring the pin as an output
pin.Write(GpioPinValue.Low); //let's enable the pin as low state => 0 volt
}
public MainPage() {
this.InitializeComponent();
InitGPIO(); // let's call the procedure
}
after compiling we should be able to turn on the led
Step 5: Let's Try It
To deploy it on raspberry Pi 2, you have to use remote debugging.
Here is the guide
If you prefer, I've attached to this instructable a working solution for visual studio 2015.