Advertisement

Arduino LCD Enhancement

The most popular display system widely used in Arduino projects is the liquid crystal display (LCD). LCD displays consists primarily of two sheets of polarized glass plates with a thin layer of liquid crystal solution sandwiched between them.

The type of liquid crystals used have very specific properties that enable them to serve as effective shutters that open and close to block or let light through in response to an electric current. The current through the liquid crystals is controlled by a voltage applied between the glass plates via transparent electrodes that form a grid, with rows on one side of the panel and columns on the other. As the electric current passes through these liquid crystals, they untwist to varying degrees, depending on the voltage applied. This untwisting effect will change the polarization of the light passing through the LCD panel. As the polarization changes in response to the applied voltage across the glass plates, more or less light is able to pass through the polarized filter on the face of the LCD.

16×2 Character LCD

The general purpose 16×2 Character LCD is very easy to interface with any microcontroller , and this LCD is really very cheap and thoroughly available in the whole world. The 16×2 Character LCD (based on HD44780 LCD Controller) uses 8 data bus lines (D0/DB0 – D7/DB7) and 3 control signals (E: Enable, RS: Register Select, R/W: Read/Write).

ALC-1

When interfacing with a microcontroller, VSS and VDD pins of the 16×2 Character LCD is connected to 0V (GND) and +5V (VCC) of the concerened circuit respectively. The V0 (also labelled as VEE) connection is for contrast control, and a potentiometer (10K) is usually attached to this terminal. Normally, the R/W terminal is tied to ground. For backlighting purpsoe, 5V dc supply is fed to the backlight pins BL1 and BL2 (also labelled as LED+/BL+ and LED-/BL-) through a suitable current limiting resistor (for instance, with a 100-Ohm one). All remaining connections of the 16×2 Character LCD are solely reserved for the microcontroller interface.

ALC-2

16×2 Character LCD & Arduino

You can find numerous “16×2 Character LCD and Arduino microcontroller” projects everywhere in this website. Instead of a new wheel around, this time we are focusing more on the backlight system of the 16×2 Character LCD. How to use an Arduino for controlling the backlight unit of a 16×2 Character LCD? In order to control the the backlight LED brightness, combination of a medium-power transistor (BC327) and Arduino’s pulse width modulation (PWM) feature to adjust the effective voltage supplied to the backlight LED is used here. The transistor serves as a current sink, and its base is connected to Arduino pin 3 (D3) to apply pulse width modulation control. The wiring diagram and sketch for a simple experiment is shown below.

ALC-3

/* This sketch controls the backlight pin of the lcd, and fades the backlight in a pleasing style automatically */
int bLED = 3;
int brightness = 0;
int fadeAmount = 5;
void setup() {
   pinMode(led, OUTPUT);
}
void loop() {
   analogWrite(bLED, brightness);
   brightness = brightness + fadeAmount;
   if (brightness == 0 || brightness == 255) {
      fadeAmount = -fadeAmount ;
   }
   delay(300);
}

Next is a different sketch to turn on (and flash) the backlight only when ambient light level is very low. Little additonal hardware is required here, so refer its wiring diagram shown after the sketch. Note that you should alter the analog value in the line ‘if (lightsensorValue >= 512)’ according to your own specific light sensor hardware.

#define lightsensor 0 // photoresistor-LDR- input pin A0
#define backlight 3 //backlight output pin D3
int lightsensorValue;
void setup() {
   pinMode(backlight, OUTPUT);
   digitalWrite(backlight, LOW);
}
void loop(){
   lightsensorValue = analogRead(lightsensor);
   if (lightsensorValue >= 512) // see note
   {
      digitalWrite(backlight, HIGH);
      delay (2000);
   digitalWrite(backlight, LOW);
   delay (1000);
   } else {
      digitalWrite(backlight, LOW);
   }
}

ALC-4

This is the photograph of the 16x2 Character LCD, modified and used by author for all experiments described here.

This is the photograph of the 16×2 Character LCD,
modified and used by author for all experiments described here.

16×2 Character LCD – Contrast Control

As noted, contrast level of the LCD can be varied by varying the bias voltage on its pin 3 (V0/VEE). For this, we added a small potentiometer to this pin to control the contrast level to optimum/desired level. However, if you want a fixed contrast level then you can replace the potentiometer component with a resistor-diode setup as shown below. This gives a solid DC level (0.65/0.7 V) at the input of the Vo pin (contrast adjust) on the LCD.

ALC-6

Like the backlight, with the help of a little hardware, software-controlling of lcd contrast is also possible. This tutorial shows a way to control the backlight and contrast level in a 16×2 LCD via software with an Arduino, controlling the backlight turned on for certain time (which saves energy) and the contrast through buttons : http://garagelab.com/profiles/blogs/software-controlled-backlght-and-contrast-on-a-2×16-lcd-display

ALC-7

Be confident, this article helps you to fabricate your own microcontroller projects with enhanced display systems. With a little skill and patience you can add lcd backlight/contrast level control codes in your existing sketches. However, the ideas presented here cannot hope to cover every application. For this reason be prepared to do some experimenting to get the results you want!

Other Related Links:
http://www.jeremyblum.com/tutorial-13-for-arduino-liquid-crystal-displays/
http://www.freetronics.com.au/pages/lcd-keypad-shield-backlight-control
http://mind2move.com/m2m/arduino-lcd-shield/

No Comments

Join the conversation!

Error! Please fill all fields.
Looking for the latest from TI?