Home NetduinoNetduino Tutorials Basic Netduino example

Basic Netduino example

If you are a .Net developer and wanted to get into Arduino then the Netduino is what you need. The hardware is generally pin compatible with the arduino. Here is a picture of the original netduino board

netduino

netduino

Setup

You will need to download and install a few items of software, lets go through them. I used the 2a and 3a steps below as I have a netduino

1/ Visual Studio : Visual Studio 2010 is what I have tested this with.

2a/ Either .NET Micro Framework SDK v4.1 for netduino, netduino plus, and mini

2b/ or .NET Micro Framework SDK v4.2 for netduino 2, netduino plus 2 and go

3a/ Netduino SDK v4.1.0 (32-bit) or Netduino SDK v4.1.0 (64-bit)

3b/ Netduino SDK v4.2.2.0 (32-bit) or Netduino SDK v4.2.2.0 (64-bit)

Start Visual Studio 2010. Click on the “New Project…” link. The New Project window should pop up and Visual Studio displays a set of installed templates. We want to pick “Visual C# > Micro Framework” from the list on the left. Then pick “Netduino Application” from the list on the right.  Name your project, and press OK.

This is what you should see in Visual Studio.

netduino project

netduino project

Now enter the code below

Basic example

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoApplication1
{
public class Program
{
public static void Main()
{
// write your code here
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
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
}
}
}
}

 

netduino led flashing

netduino led flashing

Programming

Click on the Project menu and select your project’s properties. When the project properties appear, click on the .NET Micro Framework category on the left side. You need to change your deployment target from the default Emulator to the Netduino. Change the Transport from “Emulator” to “USB” and then make sure that the Device selection box shows your Netduino. If it doesn’t, unplug and re-attach your Netduino.

netduino properties

netduino properties

Now building your example will upload the code to the Netduino and you should then see the LED flash, you can see this below

netduino led flashing

netduino led flashing

 

Links

 

Netduino 2 from Amazon US

Netduino 2 from Amazon UK