Thomas James Just a geek.

Technology, Gadgetry, Photography and Software Development

Freetronics 16x2 LCD on the NetduinoPlus

by

Since I got my netduino, and shortly after the netduino plus, I’ve been dying to get a few accessories to play with. Making the on-board LED flash isn’t the most exciting thing in the world. So when [Little Bird Electronics](), the guys i bought the netduino from, advertised a one day 20% all freetronics gear sale i jumped on the chance to grab a few accessories and with next day express shipping for $8 it was a no-brainer.

The haul:

  1. 16x2 LCD using HD44780-compatible display & keypad shield
  2. AM3X Accelerometer Module
  3. 433Mhz receiver shield

Getting it up and running wasn’t the simplest task for a non-electrical-engineer software developer like myself. I scoured the internet for articles & blog posts of someone that had done it before me, but alas, there were none. So i started to research how i would do it on the Arduino and how others have got lcd panels working no the netduinos. It also doesn’t help that the MicroFramework doesn’t have an LCD display library built-in for the task.

Thanks to articles below however there is hope, the LCD library for the Arduino has been ported and is available on codeplex as the μLiquidCrystal. Reading the articles and the example code that came with the library i was able to determine i could use the direct GPIO TransferProvider. The freetronics LCD goes one step further and allows you to just line up the pin labels on the LCD with the labels on the netduino and use those as the GPIO inputs to the TransferProvider.

Code to initialise the freetronics 16x2 LCD:

// initialise the LCD display
var ledPort = new OutputPort(Pins.ONBOARD_LED, false);
var backlightPort = new OutputPort(Pins.GPIO_PIN_D3, false);
var lcdProvider = new MicroLiquidCrystal.GpioLcdTransferProvider(
    Pins.GPIO_PIN_D8,  // RS
    Pins.GPIO_PIN_D9,  // ENABLE
    Pins.GPIO_PIN_D4,  // D4
    Pins.GPIO_PIN_D5,  // D5
    Pins.GPIO_PIN_D6,  // D6
    Pins.GPIO_PIN_D7); // D7
var lcd = new Lcd(lcdProvider);
lcd.Begin(16, 2);

Code to update the display:

lcd.Clear();
lcd.SetCursorPosition(2, 0);

lcd.Write("Ready ... ");

while (true)
{
    // set the cursor to column 0, line 1
    lcd.SetCursorPosition(0, 1);

    // print the number of seconds since reset:
    lcd.Write((Utility.GetMachineTime()).ToString());

    ledPort.Write(true);
    Thread.Sleep(350);

    ledPort.Write(false);
    Thread.Sleep(250);
}

Running display:

References:

comments powered by Disqus
  • profile for Thomas James on Stack Exchange, a network of free, community-driven Q&A sites

4g android appharbor apple asp.net atrix aws barcamp beer blog brew-smith coding conferencing deployfu docpad ec2 engineering fusion-garage grid10 homebrew hp-mini information insertdatahere ipad joojoo kernel knowroaming leadership linux macbook-air moncai mono n900 ndc netduino netmf open-source opinion pcengines-apu poor-experience professional public-speaking rant ravendb reflection router singapore talks travel ubuntu unconference vagrant vps wifi windows yubikey