Created
July 4, 2017 01:27
-
-
Save jamessdixon/b351af631ad02853bb51f40086361c43 to your computer and use it in GitHub Desktop.
UWA for IoT targeting a RP2: Blinkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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