EAGLE library for 16X2 and 20X4 LCDs

These are the parts that I have used for quite some time for all circuit boards I designed that have LCDs. Free for the grab but please check the dimension of your LCD before using them as some suppliers have smaller/larger mounting holes and not all LCDs have the holes at the same locations. Some parts have only 3 mounting holes since the bottom right corner of the LCD would be right above the GPS connector on phi-2 shields. The 16X2 LCD with connectors on bottom left have been used for some projects too.

Link: http://code.google.com/p/phi-prompt-user-interface-library/downloads/detail?name=HD44780LCD.lbr&can=2&q=#makechanges

More about different LCD backpacks

Last time I discussed what serial LCD to buy. This time, as a response to some Arduino forum questions regarding I2C LCDs, I’ve written the following short comparison to prove that serial LCDs are better choice than I2C LCDs in most projects.

First, there is no official I2C liquid crystal library. Anything not included in arduino IDE 1.0 is contributed by one person or another and some get active support but the rest don’t so they are dead. Most ebay sellers are just selling I2C LCDs because they think they make money selling but not able to do any support and that’s why I put support at top priority. Just read comments on my blog you will see. Unfortunately mine is not I2C (IE cheapest, for good reasons). Just to clarify, although you can get a lib for an I2C LCD, the library goes with the particular I2C LCD and is not useful if you switch to another I2C LCD. Also arduino still does the heavy lifting to communicate with the LCD so your code will be long with the included lib and arduino spends processing time to do the LCD control. On the other hand, serial LCDs (on TTL serial) require no library so there won’t be a time when you want lib and the lib is not up to date and won’t compile. Also the serial LCD controller does all the heavy lifting for arduino. Your code is small since there’s no lib to include. Those are some of the reasons I make and sell serial LCDs and not I2C IO extender LCDs.

Two different I2C LCDs and why one is so much cheaper than the other/serial LCD:
1) LCD with I2C IO port extender (cheap). The port extender is a buck each. There is no “brain” on this type of I2C LCDs. The extender simply adds more IO ports to arduino. Arduino still does all heavy lifting and is prone to long compiled sketch and broken library problems.
2) LCD with controller that talks I2C with arduino (expensive). The controller is a few bucks and needs support such as crystal caps etc. There is a “brain” on this type of I2L LCDs. The controller does all heavy lifting so arduino has short sketch but there is still potential for broken library problems since most of these come with libraries to tell the controller what to do.

3) Then the serial LCD. It’s around the same price and complexity as 2) in terms of price and sometimes a serial LCD offers I2C connectivity as well. It’s not prone to broken library since everything is sent in serial text streams and arduino also has short sketch. You can also connect this type of LCD directly to a PC with a USB TTL adapter! The input and output are both asynchronous and buffered against overflow on arduino and serial LCD. — I’d go with this one, especially the best ones, designed by Liudr. ­čśë

Update:

Reply from brunialti at Arduino forum (agreed to be reposted here):

That is a really good introduction on choosing an lcd!
I like your approach, and I saw your serial LCD. There is a lot of “brain” inside. I think that it could be the appropriate choice for many projects and you tempted me to buy it (damn!).
On my side, as I’m going to integrate as many I2c device as possible, I would prefer not to manage two interfaces at the same time. The I2c has a strong point on its bus. You can buy a passive, small and cheap backplane and connect all the i2c devices you like, using 4 mu pins at all!

There is also a drawback in putting too much “brain” into devices: with the “brain” you put also logics, syntax and structure. That make impossible a drop-in substitution of a smart LCD with an other one.
That is similar to the broken library problem: you have to change the app code instead of the library code.

My reply to brunialti:

Very good points! Indeed I worried about that (different serial LCDs speak different commands), so, I have used all ANSI escape codes as much as I can so all functions are ANSI escape code driven or ASCII control code driven. So if you want to clear screen, that is \f (old speak for printer to spit out the entire sheet and ready a new sheet, feed). If you want to change LCD coordinates, you do the ANSI escape sequence “CSI n ; m H”, which is say “\e[2,4H” for 2 row and 4 column with 1-based numbers. I wish every serial LCD speaks ANSI, which is by far the most appropriate standard for a character display, but only few do and mine speaks the most ANSI words. All specific functions such as menus and scrolling texts are also implemented as custom ANSI escape sequence for maximal standardization. I’m pretty sure Sparkfun serial LCD won’t speak ANSI since it has a big brain but little intelligence inside. smiley-wink

http://en.wikipedia.org/wiki/ANSI_escape_code

Serial LCD backpack

Since my success on phi-panels with integrated keypads, I’ve decided to make a serial LCD backpack as well. This backpack will support membrane matrix keypads and buzzer off board with all the same great features of the original phi-panels, just cheaper and more flexible if you want the serial backpack to make the least impact to how your project has been set up. Here it is:

At the moment, I only have 16*2 and 20*4 displays in stock but you should have no problem with 20*2 display and 40*2 displays. If in the rare occasion your display has double row pin holes, you can always solder wires between your display and the backpack.

You can set the size of the display over serial or on the on-board menu, with a 4*4 membrane matrix keypad.

This is the cheapest serial backpack out there. The I2C backpacks sold by adafruit etc. don’t have any processors on them so they will waste your arduino just as much time and FLASH space to operate as a parallel display. With the vast 24KB on-board firmware and functions, this backpack trumps any of its competitors!

I am offering these for sale on inmojo at the moment, although if you are interested in trading with me (I collect old CPUs, in the early 1990’s and earlier), I can trade with you as well. Read this post if you are interested in exchange:

https://liudr.wordpress.com/2011/04/09/exchange/

Arduino character art on LCD

The posts on arduino forum by JO3RI inspired me to make the following:

I used an arduino, Phi-1 shield, and phi-menu to create some animation art. His arts were very awesome but mine is lame. Anyway, here it is:

Here is how I constructed my codes with my latest Arduino Phi-menu software. The code download is in the end:

We need three menu items:
1. Display the animated arts
2. Set parameters, such as speed of the animation, forward or backward, and which animation to play
3. Display credits.

First, take a quick look at the FUNCTIONS.pde

Then add your menu texts in the menu_item00 and menu_item01 strings (in red) and add more menu items as you need (in green) . Make sure you enumerate all these strings in the later array (in green).

Now define some variables that you will be using in your program here after the comment line (in green).

Scroll down in FUNCTIONS.pde and find the switch command. Make sure you add additional menu items in the function (in green).

We code the parameters function first. We have three parameters, delays, art_number, and _forward. In parameters function (menu_function_0), we need to ask user to adjust each parameter at a time. You first prompt the user with a string such as “Delays” (in red) so the user knows what he is adjusting. Then you assign the value of the parameter, such as “delays”, to a temporary variable para_val (in purple). This way if the user changes the value and decides to escape, the original value of delays is not disturbed. Then invoke the hmi function. It handles everything, displays the current value of the parameter, sets the up and down keys to change the value, with lower and upper limits, and step size per key press. Once the user is happy with the value, it returns. Details of how to use the hmi function is in the documentation.
The last line in the block updates the parameter only if the user presses confirm. If the user actually escapes, the parameter is not changed.

In the body of the FUNCTIONS.pde, you will define menu_function_1. such as the following image:

In the body of the FUNCTIONS.pde, you will define menu_function_2. such as the following image:

Source code:

Character art with Phi-menu for Phi-1 shield

Generate character LCD images for illustration

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

The above are definitely not pictures I took on my LCD but look just like one, only much better. How did I make them? I have recently made a Phi-1 shield with 16X2 character LCD on it. Here is a way I found to generate perfect character LCD images for manuals. How did I make them? I used Word.

First install the Ericsson font from dafont lcd font page 7: http://www.dafont.com/theme.php?cat=302&page=7

Then in Word, type the message you want, and pad with┬áenough characters┬áso both lines are 16 characters. Say if you want “Read data list”, you want to type “Read data listaa”. Then┬áselect everything, then use green high lighter. Then choose the padding “aa”, use the same green as the font color so they will be invisible and all you see is “Read data list [2 spaces]”.┬áTada!

Here is more illustration:

How to connect Arduino with a character LCD

A character LCD can be pretty useful to an Arduino project since Arduino has no display itself. You see them everywhere: vending machines, laser printers, fax machines, etc. You can use the serial port to output information to a PC but that ties the Arduino to a computer. Arduino can do a lot without a PC, taking data and interacting with a user at the same time.

There are many types of LCD, color, mono, dot-matrix, character. A color LCD is always dot-matrix. Some even has touch sensors. We won’t need a color display since information we will display┬áwon’t be more useful with a fancy display. The┬ámore complex the display gets,┬áthe more resources it consumes. An arduino┬áhas 20 general I/O lines. A character display uses 6, a dot-matrix display uses 14. In order to use a color dot-matrix display, a microcontroller needs a lot┬á┬áof memory and send a lot of data to the display,┬áneither of which is what Arduino is best for. The simpler, the better. We will use a mono character display. We need a display for information.

Once in a while you see a teaching equipment company comes up with a handheld all-in-one lab measurement equipment with color display and touch screen. It’s tempting but most of the function it does like spreadsheet, and calculation, can be much better done with even an entry-level netbook. So we’re better off letting what lab equpiment does best, measurement, and leave data analysis to a PC. Enough of unhappy feelings towards teaching equipment companies.

Back to how to hook up a 16 column X 2 row character display.

You can find a very cheap one here:

´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐http://www.dipmicro.com/store/LCD-1602A-Y

´╗┐

Make sure you pick up some male header pins and a 10KOhm potentiometer:

http://www.dipmicro.com/store/HEADS40T

http://www.dipmicro.com/store/R4V10-3386

An LCD has a total of 16 pins. Here is a list of all pins and functions:

Pin 1 GND

Pin 2 +5V

Pin 3 Contrast

Pin 4 RS (Register select)

Pin 5 R/W (Read or write)

Pin 6 EN (Enable signal)

Pin 7~Pin14 D0~D7 (Data)

Pin 15 A (Anode of back light LED)

Pin 16 C (Cathode of back light LED)

Luckly we only need to connect 6 of above pins to Arduino, and 5 additional pins to +5V, ground, or potentiometer.

If you want to do this on a breadboard, you will need some soft jumper wires.

First, you need to solder the male header pins to the LCD. Just break away 16 pins from your 40-pin male header pins, push them through the LCD pin holes and use possibly this iron (http://www.radioshack.com/product/index.jsp?productId=2062758). If you can’t find this in your local store, find a similar one around 30W and a sharp tip.

The LCD won’t stand well on its own with the pins. My trick is to take a piece of eye-glass┬ácleaning cloth, fold it a couple of times, then stick it underneath the LCD as support. First heat up your iron for at least 3 minutes. Then add a little bit of solder to the tip. Wipe excess with sponge. Stick the tip of your iron against the first pin. The first pin takes a while to heat up. Just patiently count to 15. Bring the solder to the pin not the tip of the iron. If the solder melts, good, add around 1/4 inch of solder, wait for the solder to grab on the pin and get sucked in the pin hole. Move on to the next pin. If the solder doesn’t melt, don’t force it against the iron, just wait a few more seconds. When the pin and the hole are both hot enough, the solder will stick or wet them. The curvature is just the opposite when you force melted solder against cold pin.

Finish off all the pins. Check for shorts.

Now push your LCD into your breadboard, keep your Arduino near the LCD. Use a couple┬áof jumper wires, bring the +5V and GND to the breadboard’s power rails. Add the potentiometer near the LCD pin 1. Connect left pin to +5V and right pin to GND. Connect the following LCD pins:

Pin 1 GND

Pin 2 +5V

Pin 3 middle of the potentiometer

This should power the LCD logic and contrast.

Now turn the potentiometer until you can see a row of black boxes on the display. This confirms that your display is working.

Now connect the following LCD pins:

Pin 15 +5V

Pin 16 220 Ohm resistor

The other side of the resistor goes to GND.

This should power up the LCD back light. If the back light is too dim, reduce the value of the resistor. Don’t connect Pin 16 directly to the ground. Doing so will reduce the life time of the back light by a lot. Most spec sheets tell you what to do regarding series resistors on back light. In doubt, try a 150 Ohm. Then gradually dial up or down the number (with a pot) to find the brightness you need.

I would turn my lights off at night and dial the brightness just enough for comfortable viewing in the dark. In this case the back light is not visible in well-lit rooms, which doesn’t need back light in the first place.

Now connect the following LCD pins to Arduino pins:

Pin 4 RS to Arduino digital Pin 7 (green on the left)

Pin 5 R/W to GND

Pin 6 EN to Arduino digital Pin 6 (orange on the left)

Pin 11~Pin14 D0~D7 (Data) to Arduino digital Pins 5~2. (blue, green, orange, white)

From left to right on LCD, black(GND), red (5V), blue (potentiometer middle), green(RS),orange(GND),another orange(EN, sorry running out of jumper wires), not connected (next 4 pins), blue, green, orange, white (D4-D7), red(5V), resistor (to GND)

We don’t need all 8 data pins. The LCD can work at 4-bit data mode, which saves 4 Arduino pins.

Now load the HelloWorld example code in Arduino IDE under examples->LiquidCrystal.

Make sure you change the line with LiquidCrystal(x,x,x,x,x,x); to LiquidCrystal lcd(7, 6,  5, 4, 3, 2);

Compile the sketch and upload it to Arduino. It should show “hello, world” and followed by a second count. If you’ve gone this far, you’ve made it. Go ahead and load more examples and modify them to learn how to work with the LCD. It’s easy, like LCD.print(“This is a message”);

If you want a more permanent installation of an LCD, instead of 12 loose wires, look at my Phi-1 shield. You can directly plug the LCD on the shield to make connection or take it off for a different project.

%d bloggers like this: