Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.

Making an LED Blink with Netduino

This entry is part 1 of 2 in the series Netduino Experimenters Kit offers a reasonably priced Inventor's Kit for people new to electronics. It currently only offers this bundled with an Arduino Uno, however in the hopes that it will offer a Netduino version, or one without a bundled microcontroller, or simply for people interested in learning multiple platforms, I'm converting the code to a .NET/C# version. The materials of the kit are released under the Creative Commons license. Many of the images, diagrams, and other materials below came directly from or were derived from SparkFun/.:OOMLOUT:.

LEDs (light emitting diodes) are used in all sorts of clever things which is why we have included them in this kit. We will start off with something very simple, turning one on and off, repeatedly, producing a pleasant blinking effect. To get started, grab the parts listed below, pin the layout sheet to your breadboard and then plug everything in. Once the circuit is assembled you’ll need to upload the program. Start a new Netduino project in Visual Studio and use the code example below to create your programs. Ensure you’ve selected the Netduino USB device to deploy to (see the other beginner tutorials for instructions) and run the program to deploy the program to your device.

Parts Required

  • Breadboard
  • 5mm Yellow LED (or any color you’d like)
  • Jumper wire
  • 330ohm resistor (orange-orange-brown)

Project Code

using System;
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace CIRC_01
    public class Program
        public static void Main()
            //Create an Output port to control an LED on digital pin 13
            OutputPort led = new OutputPort(Pins.GPIO_PIN_D13, false);
            //A while-loop will make our code loop indefinitely
            while (true)

How It Works

First an instance of an OutputPort is declared, named ‘led’ and tied to GPIO pin 13, which is where we connected the LED. It’s initial value is set to false (off).

An endless loop then cycles between two states. led.Write(true); sets the pin to HIGH which turns on the LED, likewise turning it to false turns off the pin and LED. Thread.Sleep(1000); instructs the microcontroller to “sleep”, or wait, for 1000 milliseconds, 1 second.


Further Learning

  1. Make the flashing faster or slower
  2. Make the flashing durations different (on for 2 seconds, off for 1)
  3. Connect the LED to a different IO pin on the netduino and change the code to work with the new pin
  4. Connect a second LED which is on when the first one is off
Series NavigationFun with 8 LEDs and the Netduino >>