Gadgeteer Hello World

.NET Gadgeteer Videos Demos


Introduction

Some time ago, I posted an unboxing video for something new, my FEZ Spider .NET Gadgeteer starter kit. Since then, I've been busy with both my day job, and spending a lot of my "free" time playing with my Gadgeteer stuff, learning about breadboarding, and generally diving head-first into the world of electronics hardware and microcontrollers.

At first, working in this world was quite indimidating, and I felt almost completely lost. I plugged my first board into my computer with the LCD screen hooked up, and all it showed was some debug information. OK. Where do I go from here, I asked myself?

To help other folks who might be in the same boat (whether you're a software geek just jumping into Gadgeteer, or someone experienced with other electronics work, but not familiar with Gadgeteer), I'm going to start posting some blog/video posts walking you through the basics of working with .NET Gadgeteer. Some of this information (such as breadboarding, for example, which I'll cover in a future post) may be applicable to other microcontroller environments, while some will be Gadgeteer-specific.

In this post, I'm going to take you from receiving a .NET Gadgeteer mainboard to the "Hello, World" of embedded electronics, which is flashing an LED.

Video Experiment

A side note on the videos…I'm trying an experiment here and recording and posting these videos quickly, with little or no processing or editing, in hopes that keeping the process lightweight will help me get more videos out more quickly. Set your expectations on the video quality appropriately.

I Just Got My FEZ Spider Starter Kit (or similar Gadgeteer-compatible mainboard)…Now What?

If, like me, you go the starter kit route, you've spent a little more money, but you now have a mainboard, and a bunch of modules, most of which you probably have no idea what they do, or what to do with them. DON'T PANIC! We'll start slow with the first video.

Prerequisites

Since I already have the necessary software (Visual Studio, .NET Micro Framework, Drivers, etc.) on my machine, I'm not going to show installing those as part of the video. If you're working with GHI gear, you want to head over to:

http://www.tinyclr.com/support

and download and install the items under "System Preparation" before going further. This will give you the tools and SDKs you need to get started. It may even open the local version of the Getting Started guide, but don't leap into that project just yet…watch this first:

Gadgeteer Hello World from G. Andrew Duthie on Vimeo.

That was pretty simple, and required very few lines of code. Adding a display is easy, too. We can modify the original project to also write a message out to a Seeed Studio OLED Display module with just a single line of code, thanks to the SimpleGraphics API (Mike Dodaro has a neat demo of SimpleGraphics with the GHI LCD Display module here). Here's a video of this in action:

Hello Gadgeteer - OLED edition from G. Andrew Duthie on Vimeo.

Here's my design view for the final project:

image

Here's the code from the final version of Program.cs:

   1:  using System;
   2:  using System.Threading;
   3:  using Microsoft.SPOT;
   4:  using Microsoft.SPOT.Presentation;
   5:  using Microsoft.SPOT.Presentation.Controls;
   6:  using Microsoft.SPOT.Presentation.Media;
   7:  using Microsoft.SPOT.Touch;
   8:   
   9:  using Gadgeteer.Networking;
  10:  using GT = Gadgeteer;
  11:  using GTM = Gadgeteer.Modules;
  12:  using Gadgeteer.Modules.GHIElectronics;
  13:  using Gadgeteer.Modules.Seeed;
  14:   
  15:  namespace HelloGadgeteer
  16:  {
  17:      public partial class Program
  18:      {
  19:          bool IsLedOn = false;
  20:   
  21:          // This method is run when the mainboard is powered up or reset.   
  22:          void ProgramStarted()
  23:          {
  24:              // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
  25:              Debug.Print("Program Started");
  26:   
  27:              GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
  28:              timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
  29:              timer.Start();
  30:   
  31:              oledDisplay.SimpleGraphics.DisplayTextInRectangle("Hello, Gadgeteer!", 2, 2, 100, 30, 
  32:                  GT.Color.Red, Resources.GetFont(Resources.FontResources.NinaB));
  33:   
  34:              Debug.Print("Timer Started");
  35:          }
  36:   
  37:          void timer_Tick(GT.Timer timer)
  38:          {
  39:              Mainboard.SetDebugLED(!IsLedOn);
  40:              IsLedOn = !IsLedOn;
  41:          }
  42:      }
  43:  }

Hope you enjoyed this quick stroll through Hello World for Gadgeteer. In my next post, I'll explore some of the many neat things you can do with .NET Gadgeteer, and the many modules that are already available (with more on the way!).

Another nice thing about Gadgeteer is that there's a thriving community of Gadgeteer enthusiasts (myself included) that hang out over on the TinyCLR.com Gadgeteer forum. If you have questions, stop by and ask, or just say hello!

If you enjoyed this post, why not share it with your friends? You can also subscribe to my RSS feed, and follow me on twitter for more frequent updates.

Comments powered by Disqus
Disclaimer

I work for Microsoft, but the views expressed on this weblog are mine and do not necessarily reflect the views of my employer.
All postings are provided "AS IS" with no warranties, and confer no rights.

Unless otherwise noted, all code provided in this blog is copyright © Microsoft Corporation, and licensed under the Microsoft Limited Public License (Ms-LPL). All rights reserved.

Theme: KraftPatriot by Bind.pt