Wednesday, January 12, 2011

LCD Display on Arduino

Let's hook up a LCD display to our Arduino. It is actually pretty easy to do that because there are already pre assembled boards, which can be soldered to adapter boards if you want to use a bus system for example, like I did. However, you could just connect the display board itself directly to the Arduino. Here is a simple schematic of how to do that. You can find plenty of information about LCD displays on the web. Here is a good introduction of the Hitachi HD44780, if you're interested.

To interface the LCD display with an Arduino is also made pretty easy. There already is the LiquidCrystal library which can be used with the Hitachi HD44780 or any compatible chipset. The Arduino IDE comes with an example on how to use it. I share my modified code anyway, so you can have a look at how easy it is.

Souce code:
#include <LiquidCrystal.h> // include a library headfile
// LiquidCrystal display with:
// rs on pin 10
// rw on pin 11
// enable on pin 12
// d4, d5, d6, d7 on pins 13, 14, 15, 16
LiquidCrystal lcd(10, 11, 12, 13, 14, 15, 16);

void setup() {
  lcd.begin(16, 2);

void loop() {
  lcd.clear(); //clears the LCD and positions the cursor in the upper-left corner
  lcd.setCursor(3,0); //move cursor to column 4 row 1
  lcd.print("Hi there!"); //print a message to the LCD
  lcd.setCursor(3,1); //move cursor to column 4 row 2
  lcd.print("Check out");
  lcd.print("for more");
Here it is in action:

No comments:

Post a Comment