private async void InitializeGPIO() { try { GpioController controller = GpioController.GetDefault(); if (null != controller) { // Create and initialize color sensor instance _colorSensor = new TCS34725(RGB_LED_PIN); await _colorSensor.Initialize(); _colorSensor.LedState = TCS34725.eLedState.Off; // Setup button pin _gpioPushbutton = controller.OpenPin(PUSH_BUTTON_PIN); _gpioPushbutton.DebounceTimeout = TimeSpan.FromMilliseconds(100); // 100 ms _gpioPushbutton.SetDriveMode(GpioPinDriveMode.Input); _gpioPushbutton.ValueChanged += gpioPushbutton_ValueChanged; // Setup LEDs // Red _gpioRedLED = controller.OpenPin(RED_LED_PIN); _gpioRedLED.SetDriveMode(GpioPinDriveMode.Output); _pinValRed = SetGpioPinState(_gpioRedLED, GpioPinValue.High); // HIGH == ON _timerRed = new DispatcherTimer(); _timerRed.Tick += timerRed_Tick; // Green _gpioGreenLED = controller.OpenPin(GREEN_LED_PIN); _gpioGreenLED.SetDriveMode(GpioPinDriveMode.Output); _pinValGreen = SetGpioPinState(_gpioGreenLED, GpioPinValue.High); // HIGH == ON _timerGreen = new DispatcherTimer(); _timerGreen.Tick += timerGreen_Tick; // Blue _gpioBlueLED = controller.OpenPin(BLUE_LED_PIN); _gpioBlueLED.SetDriveMode(GpioPinDriveMode.Output); _pinValBlue = SetGpioPinState(_gpioBlueLED, GpioPinValue.High); // HIGH == ON _timerBlue = new DispatcherTimer(); _timerBlue.Tick += timerBlue_Tick; _isInitialized = true; Debug.WriteLine("All pins initialized"); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }