Using a 5 volts serial LCD backpack with a netduino

Lost In Translation

A while ago, I bought a LCD117 serial LCD backpack from Modern Device to save a few pins on my Arduino board. Everything worked great because the micro-controller, the serial backpack and the LCD display all required 5 volts for power and logic levels.

But when I tried connecting the serial LCD backpack to a netduino micro-controller, nothing worked: the netduino uses 3.3 volt logic levels while the LCD117 serial backpack expects 5 volt logic levels.

That’s annoying.

Fortunately, there’s a simple and inexpensive solution called a ‘Hex non-inverting buffer’ which can translate between logic levels. I happened to have such a chip, in this case, a  NXP HEF4050 which can be found for less than 50 cents a piece from DigiKey.

I wanted to use the TX pin (digital pin 1) of COM1 of the netduino to print out text messages, so I wired the 4050 like this:

Here’s a code snippet sending a “Hello World!” message to the LCD screen:

using System;
using System.IO.Ports;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace SerialLCD
{
public class Program
{
public static void Main()
{
using (var port = new SerialPort(Serial.COM1, 9600, Parity.None, 8, StopBits.One))
{
port.Open();
string Msg = "Hello World!";
var buffer = new byte[1];
foreach (Char c in Msg){
buffer[0] = (byte)c;
port.Write(buffer, 0, 1);
}
port.Flush();
port.Close();
}
}
}
}

Hello World!

Happy Hacking!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s