Jeroen Swart

.NET Architect

Netduino - Getting Started with LCD

If you want to show more output then blinking LED’s, an LCD module is a good and usually affordable option. They come in different sizes, from 2 numeric-only digits to 40x4 alphanumeric dot-matrix modules. You can also get graphic LCD’s, that range from modules with small resolutions (e.g. 122x32 or 240x128 pixels) to more professional LCD screens (e.g. 5” or 7”),  but I will stick with alphanumeric LCD’s for this post.

Most alphanumeric LCD modules are built around a HD44780 or compatible controller, so they all use the same interface. They are controlled using an 8-bit parallel port, some pins for handshaking (controlling the transfer of data over the parallel port), pins for controlling the contrast and backlight if available and of course pins for power and ground. The parallel port can also be used in 4-bits mode, sending the 8-bit data in two write actions. This saves I/O ports, but takes more time to update the LCD.

There is an excellent library available on codeplex (with a good introduction on the blog of the author) for controlling LCD modules. This library makes showing text on a display as easy as calling a Write method with the desired string. It uses a provider-pattern to allow for different connection scenarios, like direct on GPIO pins, using a shift-register or using an I2C expander. And if you want to use another scenario, you can add your own provider.

I have a 20x2 LCD module that I connected directly to the GPIO pins of my Netduino using the parallel port in 4-bit mode. The connections are made on a breadboard, because this makes it a little easier to put all the wires together. Below is an image of the result. The sample code provided with the library contains a link to a very helpful schematic on the Arduino website. Remember to connect the power on the LCD module to the 5V of the Netduino. 3.3V is not enough and will leave the LCD blank.

 The library contains a simple example of how to use the library. It initializes the LCD, shows the obligatory “Hello world” and then enters a loop that shows the milliseconds since reset. Since I use the GPIO pins directly, I changed the provider in the example. The code I used is shown below.

public class Program
    public static void Main()
        // create the transfer provider, use direct GPIO provider
        // Initialize the library with the numbers of the interface pins
        // Use wiring shown here
        var lcdProvider = new GpioLcdTransferProvider(Pins.GPIO_PIN_D12,    // RS
                                                        Pins.GPIO_PIN_D11,    // ENABLE
                                                        Pins.GPIO_PIN_D5,     // D4
                                                        Pins.GPIO_PIN_D4,     // D5
                                                        Pins.GPIO_PIN_D3,     // D6
                                                        Pins.GPIO_PIN_D2);    // D7

        // create the LCD interface
        var lcd = new Lcd(lcdProvider);

        // set up the LCD's number of columns and rows: 
        lcd.Begin(20, 2);

        // print a message to the LCD.
        lcd.Write("Hello world!");

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

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



Comments (4) -

  • Jorge castillo

    1/25/2012 11:00:35 AM |

    You have got some great posts in your blog. Keep up with the good work.

  • Chris Miller

    2/22/2012 6:55:58 AM |

    I love your post. It's very informative , thanks a lot.

  • M3mPhis

    2/3/2013 5:25:47 AM |

    Great solution!

  • javier

    3/8/2013 8:10:14 PM |

    i need  GpioLcdTransferProvider refenrence where is it?

    please help me. thanks.

Pingbacks and trackbacks (2)+

Comments are closed