private static void ButtonWait(GpioDriver driver) { using (var controller = new GpioController(driver)) { GpioPin button = controller.OpenPin(s_buttonPinNumber, PinMode.Input); if (button.IsModeSupported(PinMode.InputPullDown)) { button.Mode = PinMode.InputPullDown; } button.DebounceTimeout = TimeSpan.FromSeconds(1); button.NotifyEvents = PinEvent.SyncRisingEdge; Stopwatch watch = Stopwatch.StartNew(); while (watch.Elapsed.TotalSeconds < 15) { bool eventDetected = button.WaitForEvent(TimeSpan.FromSeconds(1)); if (eventDetected) { Console.WriteLine("Button pressed!"); } } } }