Getting started is pretty simple, especially if you already use C#.Net for other programming projects.
You'll need to install 3 things to get going:
http://www.netduino.com/
- MS Visual Studio C# Express 2010
- Net MicroFramework 4.2 SDK
- Netduino SDK v4.2.2.0 (32-bit) or Netduino SDK v4.2.2.0 (64-bit)
And of course.. you need a Netduino 2 ($34.95)
To create a new Application for the Arduino 2, open Visual Studio and create a new project.
When the dialog comes up select Micro Framework and Netduino 2 Application.
I want to debug on the real hardware, not using the Emulator. To do this I'm going to set the Project properties for the .Net Micro Framework:
- Make sure the Netduino is plugged into the computers USB port so it will show up in the device list.
- Change the Transport to USB and select Netduino2_Netduino as the device.
That's all it takes to be able to debug your code on the hardware. I can now run my code in debug mode, directly on the Netduino 2!
Now just write a little code to blink the blue on board LED (to the right of the board) in program.cs. Here is some code:
namespace NetduinoApplication1
{
public class Program
{
public static void Main()
{
// Create an Output port for the Onboard led pin and set it to false.
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
// Blink the LED
Blink(led);
}
// Blink the LED at 250ms on/off intervals
public static void Blink(OutputPort led)
{
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
}
}
}
}
Press the run button to start debugging, the blue LED will blink.. Hello World Netduino!
More information about the Netduino can be found at Netduino.com.
No comments:
Post a Comment