Netduino – hello led!

Are you a .Net developer but you also dream of doing some electronic projects, like.. blinking leds? There is a app.. err.. board, for that. Netduino is the name.

I’ll go on with a short description of what is it. Netduino is a small board, with a form factors same as Arduino, a very popular prototyping board. Netduino is easy to connect to the computer with a usb cable, all written software is deployed with a simple run button click. The software is written in C#, with the the .Net 4.1 Micro Framework. The new version of the Micro Framework, 4.2, has support for VB.

As for electronic features, it has 14 general purpose input-output ports. Connect LEDs to them and make them blink, or control the garage gates if you like.. 6 analog ports are handy if you want to hook up a temperature sensor, or any other thing that has an analog output. It can handle UART, SPI or I2C interfaces so you can add any other piece of electronics that needs a communication interface. Controling servo motors is easy as well with PWM.

Thirst thing I did when I got it was blinking 2 leds, the code is as follows (one is an onboard led another one I hooked to GPIO13):

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoApplication1
{
  public class Program
  {
    public static void Main()
    {
      OutputPort ledBlue = new OutputPort(Pins.ONBOARD_LED,
        false);
      OutputPort ledRed = new OutputPort(Pins.GPIO_PIN_D13,
        false);
      const int colorBlinkCount = 4;
      const int colorTime = 50; //ms

      while (true)
      {
        for (int i = 0; i < colorBlinkCount; i++)
        {
          ledBlue.Write(true);
          Thread.Sleep(colorTime);
          ledBlue.Write(false);
          Thread.Sleep(colorTime);
        }

        for (int i = 0; i < colorBlinkCount; i++)
        {
          ledRed.Write(true);
          Thread.Sleep(colorTime);
          ledRed.Write(false);
          Thread.Sleep(colorTime);
        }
      }
    }

  }
}

And the web site netduino.com. A place where you can buy it with reasonable shipment price sparkfun.com. As you can see on the latest link, it comes in 3 flavors, the mini, the standard and pro with network capability.

.Net FTW!

Rock Stars, Ninjas and Heroes

What this 3 have in common? Sometimes they are used to describe programmers. What follows is a characterization of each type.

Rock Star

This is the most used term out of the 3. You might even seen it in job offers ads like: “Are you a Rock Star programmer? We want you in our team… bla bla bla”.

First of all that means a person that is very good, one of the best at what it’s doing (programming in our case), but it also describes it’s character. It’s all about him. The world revolvesĀ aroundĀ him. All the others are not worthy of his attention. He is the God, as he can create what no other can. So not a team player.

Ninja

The masters in their craft, the warriors that know their weapons, and handle them like no other. Can do things faster then anybody else because they know the secret shortcuts to get a job done. Google is their best friend. Why invent new solutions when so many problems have already been solved? They will be able to reuse code and modules that the society has produced.

Hero

Doesn’t refer to one’s technical side. For a hero it’s all about getting it done. If there is a problem with the delivery of the product, the hero will step up and put everything he’s got to solving the problems and delivering the project on time. Yes, that means working late hours. Just as real heroes (not comic book ones) they burn out eventually.

C# brain teasers

Recently I’ve stumbled upon a few brain teasers on C# and it was fun trying to figure out the answers to the problems. So here are a few simple brain teasers from me.

Teaser 1

What will be displayed in the console?

void foo(int a, int b, int c)
{
    Console.WriteLine(a);
    Console.WriteLine(b);
    Console.WriteLine(c);
}

.....

int i = 0;

foo(i++, i++, i++);

Teaser 2

Will that compile?

enum E { A, B, C, }

Teaser 3

How about that:

void foo(string s) {...}

void foo(StringBuilder sb) {...}

....

foo(null);

No answers provided. You want to know the answers, you have to try it yourself, no fun otherwise.

More teasers here and here. Got a brain teaser? Drop a comment.

Next Page »