{"id":644,"date":"2016-11-23T15:08:22","date_gmt":"2016-11-23T15:08:22","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=145"},"modified":"2016-11-23T15:08:22","modified_gmt":"2016-11-23T15:08:22","slug":"rpi-io-pins","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/io-pins\/rpi-io-pins","title":{"rendered":"RPi IO Pins"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Visual Studio Requirements <\/h4>\n\n\n\n<p>Windows IoT Extension for UWP extension is needed &#8211; right clicking on your project. Then, select Add &gt; Reference..&nbsp; <\/p>\n\n\n\n<p>Select Universal Windows &gt; Exensions &gt; Windows IoT Extension for the UWP, select the latest version and press OK <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Add IO Pins Capability<\/h4>\n\n\n\n<p>(Includes adding SPI port, I2C port, etc capabilities)<\/p>\n\n\n\n<p>To enable the IO pins open &#8220;Package.appxmanifest&#8221; &gt; Capabilities Tab &gt; Select &#8220;Low Level&#8221;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Namespace <\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>using Windows.Devices.Gpio;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Using IO Pins <\/h4>\n\n\n\n<p>You can setup the IO pins in the App.xaml.cs OnLaunched() function no problem, but don&#8217;t set them up in the App() constructor <\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Defining your pins <\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/IO PINS\n\tprivate GpioPin GpioPinMotorEnable;\n\tprivate GpioPin GpioPinMySwitch;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Initialising <\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/------------------------------\n\t\/\/----- INITIALISE IO PINS -----\n\t\/\/------------------------------\n\tvar gpio = GpioController.GetDefault();\n\tif (gpio == null)\n\t{\n\t\t\/\/ERROR\n\t\treturn;\n\t}\n\n\tGpioPinMotorEnable = gpio.OpenPin(17);\t\t\t\t\t\/\/&lt;&lt;&lt;RPi GPIO## Pin number\n\tGpioPinMotorEnable.Write(GpioPinValue.Low);\n\tGpioPinMotorEnable.SetDriveMode(GpioPinDriveMode.Output);\n\n\tGpioPinMySwitch = gpio.OpenPin(18);                     \/\/&lt;&lt;&lt;Rpi GPIO## Pin number\n\tGpioPinMySwitch.SetDriveMode(GpioPinDriveMode.Input);<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Setting Output Pins <\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tGpioPinMotorEnable.Write(GpioPinValue.Low);\n\n\tGpioPinMotorEnable.Write(GpioPinValue.High);<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Reading Input Pins <\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tif (GpioPinMySwitch.Read() == GpioPinValue.High)\n\t{\n\t}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio Requirements Windows IoT Extension for UWP extension is needed &#8211; right clicking on your project. Then, select Add &gt; Reference..&nbsp; Select Universal Windows &gt; Exensions &gt; 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 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76],"tags":[],"class_list":["post-644","post","type-post","status-publish","format-standard","hentry","category-io-pins"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=644"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/644\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}