I received my Netduino last week. This is an electronics prototyping board with a microcontroller that runs the .Net Micro Framework 4.1. It’s great for someone like me who wants to focus on learning electronics without the additional step of struggling with the software language. It’s one of a number of boards that use the .Net Micro Framework rather than the usual C/C++ or specialised embedded languages to control voltages and ports.
The board itself is open source so you can build one of these yourself. It is also PIN compatible with the Arduino – another very popular board for hobbyists . What this means is that, in most cases, you can attach the same daughter boards (called shields) to your Netduino and there are quite a wide variety of these shields available. They vary in functionality from enabling wifi/ethernet connections, Joysticks and MIDI to connecting with motors and LCD touchscreens.
While waiting for the Netduino to arrive, I started with the equivalent to Hello World application.There were a few things to install to get going:
- Visual C# 2010 Express (or Visual Studio 2010)
- .NET Micro Framework 4.1
- Netduino SDK – 32-bit/ 64-bit
There’s a number of videos showing how to get started.
After installing .Net MicroFramework you will find a section for Micro Framework under the Visual C#New Projects dialog. Installing the driver for Netduino gives you a new icon for ‘Netduino Project’. If you were to buy a different board such as the Fez you would need to install the driver for that. In this way, the .Net Framework is quite generic and allows for a range of hardware. It is also another Microsoft open source project, Apache licensed, so you could in fact tailor it yourself to your own application.
The code you get when you create the new project looks indistinguishable from a standard console application, apart from a few differences in namespaces. SPOT stands for Smart Personal Objects Technology and dates back to about 2004 when Microsoft experimented with embedding .Net in wristwatches and so on. Add the lines to blink the LED and you are ready to test it works.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace Netduino.HelloWorld
{
public class Program
{
public static void Main()
{
// write your code here
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
while (true)
{
led.Write(true);
Thread.Sleep(250);
led.Write(false);
Thread.Sleep(750);
}
}
}
}
If you have a Netduino plugged in, press F5 and you will get a few messages in the status area confirming the application is deployed to your board and, hey presto, your first blinkety-blinking led. You can step through the code using the debugger, trace lines to the output window etc.. Be warned, after stopping debugging, the device will continue to flash as the the program is now running from the unit’s memory space and will continue every time it is powered on until another program replaces it. To get round this, just run the following code to turn the led off.
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); led.Write(false);
If, like me you, can’t wait to get started and your board is hanging around in some postal sorting office somewhere, you can try debugging with a Netduino emulator which is a really great idea. Its early days with this project and at the moment it works quite well if all you want to do is play with just a button and led