title: GPIO on Raspberry pi c#
body: <p>I'm currently working on a project to make a raspberry pi robot car thing using c#. I have absolutely no knowledge of c#, so this is my way of learning it.</p>
  
  <p>The car uses an L298N to control the motors, so all I need to figure out how to get the pi to output high from one pin, and low from another, then I can work out how to control it. </p>
  
  <p>But the point is, I wrote some code hoping that it would activate one of the motors, but it doesn't seem to. I was hoping someone who understands c# and GPIO pins better would be able to point out the errors. </p>
  
  <p>Thanks, Callum </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Runtime.InteropServices.WindowsRuntime;
  using Windows.Foundation;
  using Windows.Foundation.Collections;
  using Windows.UI.Xaml;
  using Windows.UI.Xaml.Controls;
  using Windows.UI.Xaml.Controls.Primitives;
  using Windows.UI.Xaml.Data;
  using Windows.UI.Xaml.Input;
  using Windows.UI.Xaml.Media;
  using Windows.UI.Xaml.Navigation;
  using Windows.Devices.Gpio;
  
  // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&amp;clcid=0x409
  
  namespace App4
  {
      /// &lt;summary&gt;
      /// An empty page that can be used on its own or navigated to within a Frame.
      /// &lt;/summary&gt;
      public sealed partial class MainPage : Page
      {
          public void GPIO()
          {
              GpioController gpio = GpioController.GetDefault();
              if (gpio == null)
                  return;
              using (GpioPin pin1 = gpio.OpenPin(5))
              {
                  pin1.Write(GpioPinValue.High);
                  pin1.SetDriveMode(GpioPinDriveMode.Output);
              }
              using (GpioPin pin2 = gpio.OpenPin(6))
              {
                  pin2.Write(GpioPinValue.Low);
                  pin2.SetDriveMode(GpioPinDriveMode.Output);
              }
          }
      }
  }
  </code></pre>