Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Run(IBackgroundTaskInstance taskInstance)
- {
- //Build the button sensor that is
- //plugged into the GrovePi at pin D2:
- var button = _deviceFactory.ButtonSensor(Pin.DigitalPin2);
- //Break out of while loop on button press
- while (true)
- {
- //Try catch to prevent error from reading
- //too quickly
- try
- {
- if (button.CurrentState == SensorStatus.On)
- break;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment