Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site
« .NET Micro Hardware Emerging | Main
Sunday
May282006

A First Program

The .NET Micro Framework exposes the hardware by means of an object model. This little snippet of code should give you some idea of how this works, and also how similar/identical the code looks to C# programs for PCs.

public static void Main()
{

    Microsoft.SPOT.Hardware.Cpu.Pin ledPin =
        Microsoft.SPOT.Hardware.Stamp.Pins.GPIO9_SER2_TDX;
 
    Microsoft.SPOT.Hardware.OutputPort ledOutput =
        new Microsoft.SPOT.Hardware.OutputPort(ledPin, true);
 
    while (true)
    {
        ledOutput.Write(false);
        System.Threading.Thread.Sleep(500);
        ledOutput.Write(true);
        System.Threading.Thread.Sleep(500);
    }
}

The program will simply flash a led connected to one of the pins.  An OutputPort instance is created from that pin and then methods on the instance are called to set the output high (true) and low (false). Note that the standard thread management code is used to pause the program for half a second after each change of state of the led.

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    all about kulartinuminto and top news

Reader Comments (10)

Nice :)
June 1, 2006 | Unregistered CommenterMateusz Kierepka
The best explination of .NET Micro Framework I have seen.
June 8, 2006 | Unregistered CommenterTLo
Hi, Rob,

Please contiunue this blog with more samples about .net micro framework. I was trying your example code, but I can't find the assembly of

Microsoft.SPOT.Hardware.Stamp.Pins

there is Cpu.Pin but no Stamp.Pins. How is this possible?
January 16, 2007 | Unregistered CommenterOguz
Sorry, the sample code is from an old version of the hardware.
January 16, 2007 | Registered CommenterRob
I am totally new to this technology and wants to learn.
can you please provide a step by step procedure to develop a simple program on .net micro framework using Visual C# which will help beginers like me.
November 19, 2008 | Unregistered CommenterKrishnaPrasad
Hello Miles! To start from the scracth using this technology, I must install VStudio 2008, and what device I can get to start some tests? I really want to start doing anything with micro framework... Can you help me? thanks.
May 14, 2009 | Unregistered CommenterLW
I hope that a red light blink at your office after I send this post :)
May 14, 2009 | Unregistered CommenterLW
To get started with the Micro Framework you need VS 2008 and the Micro Framework SDK. You can get devices from a variety of naufacturers. They have a spiffy new homepage where you can find out more here:

http://www.microsoft.com/netmf/default.mspx
May 20, 2009 | Registered CommenterRob
Rob, i see many development boards, what happens if i get to a commercial stage, will this involve designing my own board, will i need to pay licence fees to anyone? Or is it a case of develop, buy off shelf sbc, sell, sell, sell?
October 9, 2010 | Unregistered CommenterJohn
As far as I know you won't have to pay anyone anything. If you really want to roll your own device you can obtain the porting kit, build a board and just sell it.
October 9, 2010 | Registered CommenterRob

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.