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:
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).
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.Now, type the following:
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
This first line of code creates an
OutputPort. AnOutputPortis 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_LEDis shorthand that specifies the Netduino’s built-in blue LED. The second parameter (false) puts the LED ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access