I have a very simple .Net Micro Framework LED project (running on netmf 4.2 GHI code on an ARM Cortex-M4 CPU). Here is the relevant code:
using Microsoft.SPOT.Hardware;
[…]
OutputPort _RedLED;
OutputPort _GreenLED;
OutputPort _BlueLED;
[…]
_RedLED = new OutputPort(GHI.Hardware.FEZCerb.Pin.PB15, false);
_GreenLED = new OutputPort(GHI.Hardware.FEZCerb.Pin.PB14, false);
_BlueLED = new OutputPort(GHI.Hardware.FEZCerb.Pin.PB13, false);
[…]
for (var i = 0; i < numTimes; i++)
{
Debug.Print("Go white ...");
_RedLED.Write(true);
_GreenLED.Write(true);
_BlueLED.Write(true);
Thread.Sleep(2000);
Debug.Print("Go dark ...");
_RedLED.Write(false);
_GreenLED.Write(false);
_BlueLED.Write(false);
Thread.Sleep(2000);
Debug.Print("Go red ...");
_RedLED.Write(true);
Thread.Sleep(2000);
_RedLED.Write(false);
Debug.Print("Go green ...");
_GreenLED.Write(true);
Thread.Sleep(2000);
_GreenLED.Write(false);
Debug.Print("Go blue ...");
_BlueLED.Write(true);
Thread.Sleep(2000);
_BlueLED.Write(false);
}
When I run the code on the device the LEDs come on and off as expected but the output window in Visual Studio 2013 shows
[quote]Go white …
Go red …
Go green …
Go blue …
Go white …
Go dark …
Go red …
Go blue …
Go red …
Go green …[/quote]
Why aren’t all the debug statements making it through? Is Thread.Sleep the wrong ‘pattern’ to use?