Step 2: Make Sure the Board Firmware is Up to Date
Once your development environment is configured, make sure your board has the latest firmware on it. The firmware includes a customized .NETMF runtime specific to the board hardware. Firmware update instructions are here.
After you've created the project and configured the references, add the following code to your Program.cs file.
usingSystem; usingMicrosoft.SPOT; usingMicrosoft.SPOT.Hardware; usingSystem.Threading; usingSecretLabs.NETMF.Hardware.Netduino; namespaceNetduinoBlink { publicclassProgram { publicstaticvoidMain() { // configure an output port for us to "write" to the LED OutputPort led =newOutputPort(Pins.ONBOARD_LED,false); // note that if we didn't have the SecretLabs.NETMF.Hardware.Netduino DLL, we could also manually access it this way: //OutputPort led = new OutputPort(Cpu.Pin.GPIO_Pin10, false); int i =0; while(true) { led.Write(true);// turn on the LED Thread.Sleep(250);// sleep for 250ms led.Write(false);// turn off the LED Thread.Sleep(250);// sleep for 250ms Debug.Print ("Looping"+ i); i++; } } } }
This code does the following things:
It creates an OutputPort. An OutputPort allows you to "write" to a pin, e.g. power it on or off.
Loops forever: writing to the port to turn on, then waiting 250ms, then turning it off.
Prints to the Debug Window the loop iteration it's on.
Double-click on the Properties item in the Solution Explorer, select .NET Micro Framework on the left, and the under Deployment choose USB and in the Device drop down, choose your Netduino device:

Click the Start > button in the toolbar to deploy to your device.
The app should deploy and after a moment, the LED should start blinking on the Netduino:
Make sure your Netduino is plugged in. It should show up in the build bar at the top:
Hit the ">" button to deploy.
The app should deploy and after a moment, the LED should start blinking on the Netduino:
You should also see the debug output in the **Application Output** window:
Deploy: Deploying assemblies to device Deploy: Deploying assemblies for a total size of 560 bytes Deploy: Assemblies successfully deployed to device. ... Looping0 Looping1 Looping2 Looping3
Netduino.Foundation makes creating Netduino applications easier by providing a huge library of hardware peripheral drivers and a handcrafted API to use them. Check it out at Netduino.Foundation.