How to Adjust the Contrast of a Graphic LCD through Hardware and Software
This application note will present the hardware and software to control the contrast on the G12864A-FTW-LW63 Graphic Display. The display with be driven by an ST Microelectronics STM32F411RE Nucleo development board.

1. Introduction
The G12864A series of Graphic Displays, like the G12864A-FTW-LW63, have individual pixels that can either be on or off. To see these pixels several different voltages are used to excite the pixels. By applying these different voltages, the pixels can be lightened or darkened. A potentiometer or software can be used to alter the voltage that drives the pixels thereby adjusting the contrast of the display. This will be presented in this application note.
The main features of the G12864A-FTW-LW63 are:
- 4.0” Diagonal Display, 128 x 64 Monochrome Pixel Resolution
- FSTN Gray Positive
- Parallel and Serial Interfaces
- Transflective – Positive
- 3.5V White LED Backlight (other colors available)
- NT7534 Display Controller (ST7565 Compatible)
- 3V, 1/64 Duty, 1/9 Bias
2. Hardware Contrast Adjustment
The development board that will drive the display is an STM32F411RE Nucleo development (dev) board. In addition to the display and the dev board, several other hardware components are required.
- Small Breadboard
- Jumper Wires
- Variable Power Supply for driving the backlight (set to 3.5V and limited to 60mA)
- A Focus LCDs KBB5040A breakout board
- Mini-USB cable for powering and programming the dev board
Below is an image of the hardware used in this application note.

A 10k single turn potentiometer will be used to show how hardware can be used for contrast adjustment. A simplified schematic of the potentiometer connections is shown below.

Connect the display as shown in the schematic.

Using the potentiometer, the contrast was difficult to adjust for a viewable image. The above image was the best that could be obtained with a single turn 10k Ohm potentiometer.
Though the contrast can be controlled through hardware, the adjustment range is limited even with a multi-turn potentiometer. To get more adjustment, two 2.4k Ohm resistors can be attached to a 5k Ohm potentiometer. One resistor will be connected at each end of the resistive element and the wiper connected as in the above schematic. Using a 5k Ohm multi-turn potentiometer will give better results but is more expensive in cost and PCB real estate.
Finer control can be accomplished through software. This is discussed in the next section.
3.Software Contrast Adjustment
Software contrast adjustment is easier as compared to hardware. The hardware contrast adjustment requires an accessible potentiometer that could be damaged during adjustment. Software control allows for the adjustment during production or by the end user without the need to manipulate physical hardware.
There are 2 adjustments in software that control the contrast. The resistor ratio sets the overall voltage used to drive the LCD segments. Then the contrast adjustment (listed as electronic volume in the display controller datasheets: NT7534; ST7565; etc.) will fine tune the final voltage driving the segments.

Typically, the resistor ratio can be set to 0x5 hex, but as written in the comments, if the contrast is too light then 0x4 or if too dark then set to 0x6. This is the coarse segment drive voltage adjustment.

The final contrast will need to be adjusted depending on the application. Different lighting and viewing angles will need to be tested to find a suitable contrast.
In the images below the G12864A-FTW-LW63 display is shown with max, best, and minimum contrast settings.



The software contrast adjustment code can be used with several of the G12864A series of displays. Comments in the code provide typical settings for the resistor ration and contrast settings. The contrast can then be adjusted to suit the application.
Images below show the contrast on several of the G12864A series of graphic displays. The displays shown below are:



Additional Information
As discussed, hardware contrast adjustment can be used but is not the recommended control method. Software control of contrast offers improved and finer control over contrast as compared to a hardware solution.
The source code with the modifications already completed with the addition of the required code for driving the display can be provided by Focus LCDs upon request.
LCD Handling Precautions
- Do not store the TFT-LCD module in direct sunlight, best stored in a dark place.
- Do not leave it exposed to high temperature and high humidity for a long period of time.
- Recommended temperature range is 0 to 35 °C, relative humidity should be less than 70%.
- Stored modules away from condensation as formation of dewdrops may cause an abnormal operation or failure of the module.
- Protect the module from static discharge.
- Do not press or scratch the surface and protect it from physical shock or any force.
DISCLAIMER
Buyers and others who are developing systems that incorporate FocusLCDs products (collectively, “Designers”) understand and agree that Designers remain responsible for using their independent analysis, evaluation and judgment in designing their applications and that Designers have full and exclusive responsibility to assure the safety of Designers’ applications and compliance of their applications (and of all FocusLCDs products used in or for Designers’ applications) with all applicable regulations, laws and other applicable requirements.
Designer represents that, with respect to their applications, Designer has all the necessary expertise to create and implement safeguards that:
(1) anticipate dangerous consequences of failures
(2) monitor failures and their consequences, and
(3) lessen the likelihood of failures that might cause harm and take appropriate actions.
Designer agrees that prior to using or distributing any applications that include FocusLCDs products, Designer will thoroughly test such applications and the functionality of such FocusLCDs products as used in such applications.