Guest User

Untitled

a guest
Jun 4th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1.         public void Run(IBackgroundTaskInstance taskInstance)
  2.         {
  3.             //Build the button sensor that is
  4.             //plugged into the GrovePi at pin D2:
  5.             var button = _deviceFactory.ButtonSensor(Pin.DigitalPin2);
  6.  
  7.             //Break out of while loop on button press
  8.             while (true)
  9.             {
  10.                 //Try catch to prevent error from reading
  11.                 //too quickly
  12.                 try
  13.                 {
  14.                     if (button.CurrentState == SensorStatus.On)
  15.                         break;
  16.                 }
  17.                 catch (Exception)
  18.                 {
  19.                     throw;
  20.                 }
  21.             }
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment