Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamessdixon/b351af631ad02853bb51f40086361c43 to your computer and use it in GitHub Desktop.
Save jamessdixon/b351af631ad02853bb51f40086361c43 to your computer and use it in GitHub Desktop.
UWA for IoT targeting a RP2: Blinkey
public sealed partial class MainPage : Page
{
GpioPin _pin = null;
Int32 _pinValue = 0;
public MainPage()
{
this.InitializeComponent();
Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
var controller = GpioController.GetDefault();
_pin = controller.OpenPin(21);
_pin.SetDriveMode(GpioPinDriveMode.Output);
var timer = ThreadPoolTimer.CreatePeriodicTimer(TimerHit, TimeSpan.FromSeconds(2));
}
private void TimerHit(ThreadPoolTimer timer)
{
if (_pinValue == 0)
{
_pin.Write(GpioPinValue.High);
_pinValue = 1;
}
else
{
_pin.Write(GpioPinValue.Low);
_pinValue = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment