public void OpenPin(int pinNumber, PinMode mode) { if (_isSupported) { _gpioController.OpenPin(pinNumber, mode); } else { throw new NotSupportedException(); } }
private void LedBlinkingNative() { System.Device.Gpio.GpioController controller = new System.Device.Gpio.GpioController(); controller.OpenPin(17); controller.SetPinMode(17, PinMode.Output); while (true) { controller.Write(17, j % 2 == 0); Console.Write(progress[j++ % 4]); System.Threading.Thread.Sleep(100); } }
private static void InitGpio() { try { _iocontroller.OpenPin(RESET_PIN, PinMode.Output); _iocontroller.OpenPin(REL_CH1_PIN, PinMode.Output); _iocontroller.OpenPin(REL_CH2_PIN, PinMode.Output); _btnStartStop = new Button(Pi.Gpio[TA_START_STOP_PIN], GpioPinResistorPullMode.PullUp); _btnStartStop.Pressed += _btnStartStop_Pressed; _btnSelectProg = new Button(Pi.Gpio[TA_SELECT_PIN], GpioPinResistorPullMode.PullUp); _btnSelectProg.Pressed += _btnSelectProg_Pressed; _btnUp = new Button(Pi.Gpio[TA_UP_PIN], GpioPinResistorPullMode.PullUp); _btnUp.Pressed += _btnUp_Pressed; _btnDown = new Button(Pi.Gpio[TA_DOWN_PIN], GpioPinResistorPullMode.PullUp); _btnDown.Pressed += _btnDown_Pressed; } /* If initialization fails, throw an exception */ catch (Exception ex) { throw new Exception("GPIO initialization failed", ex); } }