Translate

Friday 18 April 2014

LCD Display Discovery using a 16 * 2 HD44780 LCD


While I am currently trying to find a way of interacting with my Room Management System without connecting it to a network or direct to a computer, I was playing a bit with LCD's. Reading through forum posts and tutorials, I was about to buy a new LCD since it was doing everything except printing anything to the screen.
If there are some more like me, experimenting the first time with a HD44780 LCD, don't through it out of the window while it doesn't work.
The following image is one found in plenty of tutorials. It might work with some other LCD shields but not with a HD44780.



The first and most important thing is that the LCD pin 5 (RW) has to go to ground. Second, without the back lighting (LCD pin 15 and 16) connected it is very difficult to adjust the contrast with the potentiometer only. There fore LCD pin 15 connects through a resistor to 5 volt supply. I used a 470 ohm resistor for it but you can play around a bit. Use a higher resistance if you need the back light darker an one with lower resistance if you need it brighter. A 1 to 5 k potentiometer will do the job if you need it adjustable. The LCD pin 16 goes to ground and the back light comes up.



To check it out, I rewrote a clock sketch a bit which I found in one of the Arduino books. Please be aware, that this sketch does not check with a real time clock. It uses the Arduino clock ant the time library.

#include <Time.h>
#include <LiquidCrystal.h>
#include <SPI.h> //not needed if you use the
//default library

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //create an instance of
//LiquidCrystal


void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
setTime(9,40,5,18,4,14); // set time to 9:40 Apr 18 2014
}

void loop()
{
digitalClockDisplay();
delay(1000);
}

void digitalClockDisplay(){
// digital clock display of the time
lcd.setCursor(4, 0);
lcd.print(hour());
printDigits(minute());
printDigits(second());
lcd.setCursor(3, 1);
lcd.print(day());
lcd.print(" ");
lcd.print(month());
lcd.print(" ");
lcd.print(year());
}

void printDigits(int digits){
// utility function for clock display: prints preceding colon and leading 0
lcd.print(":");
if(digits < 10)
lcd.print('0');
lcd.print(digits);
}


I am waiting for a couple of parts which I am missing in my circuit to hopefully be able to run the LCD through a shift register, using only 3 Arduino pins so I can carry on working on a small setup menu for the Room Management System.

No comments:

Post a Comment