After installation I wanted to make the onboard led, which is rather bright, flicker three times and go out.
I’ve created a LEDController and it looks like this:
public static class LedController { private static readonly OutputPort Led = new OutputPort(Pins.ONBOARD_LED, false); public static void BlinkAllLights(int times, int timingDifference) { LedController.SetLightState(false); Thread.Sleep(100); for (var i = 0; i < times; i++) { BlinkLight(timingDifference); Thread.Sleep(100); } } public static void BlinkLight(int timingDifference) { try { Led.Write(true); // turn on the LED Thread.Sleep(timingDifference); // sleep for timingDifference ms Led.Write(false); // turn off the LED Thread.Sleep(timingDifference); // sleep for timingDifference ms } catch (Exception ex) { Debug.Print("LED Control: " + ex.Message); } } }
After this I wanted a complete dark board, so that power LED still bothered me.
I’ve found this class on the Netduino forum, which allows disabling the PowerLED, EthernetPort and the SDCard.
However, those trying to save power for battery use, the power is sent to the GND, so no power savings there.
I have used that:
public static class PowerManagementController { private static readonly OutputPort[] PeripheralPorts = new OutputPort[4]; public static void SetPowerLedState(bool state) { SetPeripheralState(PeripheralEnum.PowerLed, !state); } }
So now to combine this and create 3 blinks of both LED’s and then complete darkness.
public static class LedController { private static readonly OutputPort Led = new OutputPort(Pins.ONBOARD_LED, false); public static void BlinkAllLights(int times, int timingDifference) { PowerManagementController.SetPowerLedState(false); LedController.SetLightState(false); Thread.Sleep(100); for (var i = 0; i < times; i++) { BlinkLight(timingDifference); BlinkPowerLight(timingDifference); Thread.Sleep(100); } } public static void BlinkLight(int timingDifference) { try { Led.Write(true); // turn on the LED Thread.Sleep(timingDifference); // sleep for timingDifference ms Led.Write(false); // turn off the LED Thread.Sleep(timingDifference); // sleep for timingDifference ms } catch (Exception ex) { Debug.Print("LED Control: " + ex.Message); } } public static void BlinkPowerLight(int timingDifference) { try { PowerManagementController.SetPowerLedState(true); Thread.Sleep(timingDifference); // sleep for timingDifference ms PowerManagementController.SetPowerLedState(false); Thread.Sleep(timingDifference); // sleep for timingDifference ms } catch (Exception ex) { Debug.Print("LED Control: " + ex.Message); } } }