using GHIElectronics.TinyCLR.Devices.Gpio; using GHIElectronics.TinyCLR.Pins; using System.Threading; namespace TCLR_FEZ_LED1_Btn1_INT { class Program { private static GpioPin LED1; private static void Main() { var gpio = GpioController.GetDefault(); LED1 = gpio.OpenPin(FEZ.GpioPin.Led1); LED1.SetDriveMode(GpioPinDriveMode.Output); var btn1 = gpio.OpenPin(FEZ.GpioPin.Btn1); btn1.SetDriveMode(GpioPinDriveMode.InputPullUp); // Prise en compte de l'interruption btn1.ValueChanged += Btn1_ValueChanged; Thread.Sleep(-1); // Mise en Veille pour réduire la consommation // d'énergie et permettre au système d'effectuer d'autres tâches. } private static void Btn1_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e) { if (e.Edge == GpioPinEdge.RisingEdge) LED1.Write(GpioPinValue.Low); else LED1.Write(GpioPinValue.High); } } }