Gadgeteer Hello World

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 intimidating, 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_2

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

Comment by Jon on 2012-02-07 06:26:00 +0000

Hi, love the blog, but may I recommend you get a screen capture utility for your video, its quite tedious watching code being type in the distance and it would only take someone to do better videos this way to lose most of your audience. But well done on the blog, indeed on the video as well except for the code bits!

Comment by devhammer on 2012-02-07 08:26:00 +0000

Hi Jon,

I appreciate the feedback, and I would say two things in response…one, the reason I included the entire code listing from the video was that I realized it can be a pain to see code on a video, and two, as noted early in the post this was partly an experiment to see if I could get a video post published more rapidly than I normally would be able to. I know that with a regular screencast it can take me the better part of a day to prepare, record, edit, and publish a 10 minute screencast, and that puts a limit on how much screencast work I can fit in with the rest of my obligations.

Sounds like your take is that the experiment didn’t work out so well. Perhaps for the next video, I’ll try recording the entire video as I did with this one, and replace the code-specific sections with screen-captured content. This may slow my output a little, but it may be better to do something higher-quality less frequently.

BTW, if you’d like to see some of my screencast work, check out my DevNuggets series over on Channel 9:

http://channel9.msdn.com/shows/devnuggets

Comment by J_gray22 on 2012-02-23 04:22:00 +0000

Excelent stuff – waiting for more – need some sensors and response code for some actuators, Should be good for monitoring my house security or temperature or both, Would be nice to interface through my mobile to monitor the house – start cooking the tea etc etc

Comment by devhammer on 2012-02-23 08:32:00 +0000

Glad you liked it. Definitely have more videos planned, but probably not until March at this point, as I have some travel coming up next week. But there’s more to come, including some posts on the development of the IR helicopter remote I put together with Gadgeteer. 

Code, Community, and Coffee
Built with Hugo
Theme Stack designed by Jimmy