The Hitachi HD44780 LCD module is well known not only in the hobbyist and small business but also in the professional industry which use these displays in machine/man interfaces like printers, telephones, uninterruptible power supplies, diesel generators and other industrial equipment.
This LCD is cheap, easy to use and it comes in a few number of size configurations: 8×1 (one row of eight characters), 16×2, 20×2, 20×4…
For this project I am going to use a simple library called LiquidCrystal. But don’t worry, this library is included in the standard package of Arduino 1.0.10 (or later).
For this project you need an Arduino Nano 3.0, one Hitachi HD44780 LCD module, one 10kOhm trimmer (to regulate the LCD contrast), a breadboard and wires.
Now you have to replicate the circuit below:
The code follows below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
/***************************************************************************** * Copyright (C) 2014 by Vasco Ferraz. All Rights Reserved. * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * * * * Author: Vasco Ferraz * * Contact: http://vascoferraz.com/contact/ * * Description: http://vascoferraz.com/tutorials/hitachi-hd44780-lcd/ * *****************************************************************************/ // Include the Hitachi HD44780 library #include <LiquidCrystal.h> // Initialize the library with the following Arduino's interface pins: 7, 6, 5, 4, 3, 2 // Number 7 means Arduino's digital I/O port number 7. // Number 6 means Arduino's digital I/O port number 6. // And so on... Check the schematics for more information. LiquidCrystal lcd(7, 6, 5, 4, 3, 2); unsigned char i; // Define variable "i" to be used in both loops void setup() { // Define the number of LCD's columns and rows lcd.begin(16, 2); // For this tutorial I am using a 16x2 LCD which means that there are 16 columns and 2 rows } void loop() { // This first loop prints a sequence of "x" on the first row for (i=0 ; i<=15 ; i++) { lcd.setCursor(i, 0); // Set the cursor to column i and row 0 (first row) lcd.print("x"); // Print a message to the LCD delay(500); // 500ms delay lcd.clear(); // Clear the LCD } // This second loop prints a sequence of "x" on the second row for (i=0 ; i<=15 ; i++) { lcd.setCursor(i, 1); // Set the cursor to column i and row 1 (second row) lcd.print("x"); // Print a message to the LCD delay(500); // 500ms delay lcd.clear(); // Clear the LCD } } |
For more information about this library you can read the official Arduino’s LiquidCrystal tutorial where you can find more useful functions and examples.