Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

LCD displays

by fm.

  • ST7735 - 1.8" SPI display.

  • LcdBarGraph - Turns your LCD into a bar graph, based on the LiquidCrystal library.

  • Using 4-bit mode with Hitachi LCD controllers. There are now various code examples for how to talk to an HD44780-compatible LCD in 4-bit mode (in order to save arduino pins):
by fm.

  • Using Arduino via shiftregisters to connect to LCDs (in order to save even more output pins)
    • Marc MERLIN's LCD3Wires compatible and arduino 1.0 compatible LiquidCrystal compatible (inherited) library for latching shift registers. If you have non latching shift registers, you should look at the raron and mircho's code below.
    • tomek's 4Bits documentation to make a 3 pin interface for LCDs (note, the code is not arduino 1.0 compatible and provides few primitives, see Marc's page for better code that works with the same hardware). For reference, LCD3Wires is the wiring used on the Pebble and Pebblev2 boards.
    • raron and mircho's arduinoshiftreglcd library, using a 2-wire or 3-wire connection in 4-bit mode (this code has been updated and included in Francisco Malpartida's library mentioned below)
    • Steve Hobley created a small footprint LCD driver board using a 595 shift register. Etch mask, build notes, and updated LiquidCrystal library provided here.
    • LCD library - Replacement for the original LiquidCrystal Library to control LCDs with different control interfaces: 4bit, 8bit, I2C, ShiftRegister, SPI coming soon by Francisco Malpartida. The library is faster than the original, more flexible and extendable.
by fm.

by fm.

Troubleshooting

  • LCD display is too dark or too pale. All LCDs have a contrast setting, whether it is available to you for adjustment or not. Many have backlights. The latter parts of the guide to using an external serial controller address these issues in general terms, mostly independently of controller issues.

Tip for avoiding a pot for contrast

  • Instead of using a potentiometer for the contrast setting you could use a diode and a 10K resistor. From pin 3 of the display put a diode (1N4001) to ground (pin 1 of the display). Ring on the diode should be oriented to ground! And put the 10K resistor from pin 2 (Vcc) of the display to 5V supply voltage. On several displays this gives a perfect contrast. If not then use the above mentioned 10K potentiometer. Why this is working: Measuring the voltage at the diode will give 0,65 V. And this is exactly the optimum for contrast on most displays.

Printing Numbers

The itoa() stdlib C library function can be used to convert a number into a string, in a variety of bases (e.g. decimal, binary). The buffer must be large enough to hold the largest number, plus sign and terminating null: e.g. 32 bit base-10: "-2147483648\0" = 12 characters.

The stdlib itoa() library routine adds around 600 bytes, the roll-your-own K&R implementation, which includes string.h, adds around 670 bytes. Using snprintf() from stdio.h adds just over 2200 bytes.

e.g.

char buf[12]; // "-2147483648\0"
lcd.printIn(itoa(random(1024)-512, buf, 10));