Blinking the Onboard LED

The first thing that microcontroller programmers often do is blink an LED on their new electronics board. This verifies that the board is booting up properly and that they can successfully create and run a simple app on the board.

While this can often take hours or days in the traditional microcontroller world, you’ll do it in a few minutes. Go ahead and write this Blinky app now:

  1. Now that Visual Studio is open, look for Solution Explorer on the right side of the screen. Solution Explorer shows the source and data files, which make up your Netduino project. Of particular note, the file Program.cs holds the startup code for your project. You’re going to open it and write about a half dozen lines of code. Double-click on Program.cs now (or right-click on its name and select Open).

  2. In the main section of the Visual Studio editor, you are now editing Program.cs. Click on the line underneath the text // write your code here. This is where you’ll write your code.

  3. Now, type the following:

    OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

    This first line of code creates an OutputPort. An OutputPort is a software object that lets you control the voltage level of a pin on the Netduino. The first parameter tells the Netduino which pin of the microcontroller you want to control, and the second parameter tells the Netduino which state to put it in. Pins.ONBOARD_LED is shorthand that specifies the Netduino’s built-in blue LED. The second parameter (false) puts the LED ...

Get Getting Started with Netduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.