Interfacing KS0108 Graphics LCD with Arduino

A KS0108 GLCD (Graphics Liquid Crystal Display) refers to a graphical LCD module that utilizes the KS0108 controller chip for controlling the display. This type of GLCD is commonly used in various electronic projects and embedded systems to display graphics, text, and other information.
Actually, the KS0108 took the name from its controller integrated circuit (IC) which is KS0108 mainly designed by Samsung Electronics (KS0108B controller). Here are some key features and information about the KS0108 controller based GLCDs:

  • Resolution: The KS0108 controller is often used in displays with a resolution of 64×64, 128×64 or 192×64 pixels where one KS0108 controller can control 64×64 pixels portion. This means it can control 64 columns and 64 rows of pixels. A 128×64 pixel display contains two KS0108 controllers and a display with 192×64 pixels resolution has three controllers.
  • Communication: It typically communicates with a microcontroller or microprocessor using a parallel interface with 8-bit data bus. This means it requires several data lines and control lines to send & receive commands and data to the display.
  • Graphic Capabilities: The KS0108 controller is well-suited for displaying graphics and text. It allows us to set individual pixels on or off, making it possible to draw lines, shapes, and characters on the screen.
  • Voltage Levels: The KS0108 controller often operates at 5V, interfacing it with 3.3V microcontroller may require voltage level shifter (converter).
  • Contrast Control: To adjust the contrast of the LCD, a contrast control voltage is usually applied to one of its pins. This allows to make the display more or less readable based on ambient lighting conditions.
  • Backlight: Most displays that use the KS0108 controller also include an LED backlight for improved visibility in low-light conditions.
  • Applications: Displays with the KS0108 controller are commonly used in embedded systems, instrumentation panels, and DIY electronics projects where graphical information needs to be displayed.

Interfacing a KS0108 GLCD module with a microcontroller system, such as an Arduino or another microcontroller platform, we will typically need to interface it by connecting the appropriate pins to our microcontroller’s GPIO pins and use a suitable library or driver to communicate with the display. The KS0108 LCDs communicates with the microcontroller system using a parallel interface which requires several available (unused) GPIO pins.
The KS0108 GLCD module used in this example has a resolution of 128×64 pixels, it is the one shown below:

View image of KS0108 GLCD module with 128x64 pixel resolution

KS0108 GLCD module pin description (numbering starts from right to left):

  • VSS: Ground connection pin (GND)
  • VDD: Power supply voltage pin (usually 5 Volts)
  • VO: Contrast control pin. Connect to a potentiometer to adjust the contrast of the display.
  • D/I (Data/Instruction): Data/Command (Instruction) selection pin, also labeled as RS (Register Select). Used to indicate whether data sent to the GLCD is a command or display data, with logic high for display data.
  • R/W (Read/Write): Read/Write control pin. Indicates whether data is being read from or written to the GLCD, with logic high for Read operation.
  • E (Enable): Enable pin. Used to signal the GLCD that data is ready to be processed.
  • DB0 –> DB7 (Data Lines): These are the data lines for display data and commands. DB0 is the least significant bit (LSB), and DB7 is the most significant bit (MSB).
  • CS1 (Chip Select 1): Chip select for the left half of the display (for a 128×64 display, the left 64×64 portion).
  • CS2 (Chip Select 2): Chip select for the right half of the display (for a 128×64 display, the right 64×64 portion).
  • RST (Reset): Reset pin. Used to reset the KS0108 GLCD module, active low.
  • VOUT: Negative voltage for LCD bias (usually used for LCD contrast control), also labeled as VEE. The voltage of this pin is usually -5V.
  • BLA (Anode): Anode connection for the backlight.
  • BLK (Cathode): Cathode connection for the backlight.

Note that the specific pin names and positions can vary between different GLCD modules, so it’s crucial to consult the datasheet or documentation provided by the manufacturer of the GLCD module to ensure accurate connections. Additionally, make sure to connect the pins to the appropriate GPIO pins on the microcontroller system and configure them accordingly in the code to control the GLCD effectively.
The higher resolution GLCD module 192×64 pixels has an additional CS3 (Chip Select 3) pin which is chip select for the most right third of the display (for this display the CS2 (Chip Select 2) pin is chip select for the middle third of the display.
For the chip select pins (CS1, CS2…), the KS0108 GLCD used in this project have an active high chip select pins, but there are some display modules came with active low chip select pins.

Interfacing Arduino with KS0108 GLCD display – Graphics Test Example:
This post shows how to interface Arduino uno R3 board with KS0108 128×64 graphics LCD module, project circuit diagram is shown below.

Interfacing KS0108 GLCD 128x64 pixel with Arduino circuit

Hardware Required:

  • Arduino board
  • KS0108 GLCD with 128×64 pixels resolution module
  • 20k ohm variable resistor
  • Breadboard
  • Jumper wires

Circuit description:
The connection between the KS0108 GLCD module and the Arduino uno Rev 3 board is as described below:
D/I (Data/Instruction) pin is connected to Arduino analog pin 0 (A0).
R/W (Read/Write) pin is connected to Arduino analog pin 1 (A1).
E (enable) pin is connected to Arduino analog pin 2 (A2).
DB0 –> DB7 (Data Lines) are connected to Arduino digital pins 2 –> 9.
CS1 (Chip Select 1) pin is connected to Arduino digital pin 10.
CS2 (Chip Select 2) pin is connected to Arduino digital pin 11.
RST (Reset) pin is connected to Arduino digital pin 12.
VSS (ground) pin and BLK (backlight Cathode) are connected to Arduino GND pin.
VDD (positive power supply) pin and BLA (backlight Anode) are connected to Arduino 5V pin.

The 20k Ohm variable resistor is used to control the contrast of the display, its output is connected to pin VO of the KS0108 GLCD module. The other two pins of the 20k variable resistor are connected to VDD (5V) and VOUT pins of the KS0108 module.

Interfacing Arduino with KS0108 GLCD display code:
To make the interfacing example code more simpler I used an Arduino library for the KS0108 GLCD display. This library works in dependency of Adafruit graphics library (Adafruit_GFX). Both library could be installed online through Arduino Library Manager.

For the KS0108 GLCD library, in the Arduino library manager search box write ‘ks0108’ and install the one published by Simple Circuit as shown in the video below, Arduino IDE may ask for other library installation (“dependencies,” like Adafruit_GFX or Adafruit_BusIO), if they’re not already installed then you have to add them.

The KS0108 GLCD library and Adafruit GFX libraries could be installed offline, GitHub links are below:
KS0108 GLCD library
Adafruit GFX library

The KS0108 GLCD library supports 128×64 and 192×64 pixels resolution displays depending on number of declared CS pins.
For the 192×64 GLCD resolution, the display buffer size is: 192×64/8 = 1536 bytes, and it is stored in RAM space, the Arduino uno microcontroller (ATmega328P) has only 2048 bytes of RAM space which may not be able to allocate RAM space for the display buffer. In any case the begin function will tell us if the compiler successfully allocated a space for the display buffer (returns 1 if OK).

Note that this example was tested with KS0108 GLCD library version 1.0.0 and Adafruit GFX library version 1.11.17.

Code description:
The KS0108 GLCD library contains two graphics test example for the 128×64 and 192×64 pixels resolution. The code below is the test example for the 128×64 pixel display and it was tested with Arduino UNO board and 128×64 pixels KS0108 display module with active high CS pins.

Arduino libraries required for example code are included as shown below:

The connection between the KS0108 GLCD and the Arduino is configured in the initialization of the display library:

Full Arduino code:
As mentioned above, the Arduino code is the same as the example code that comes with the KS0108 display library with no modification.

Interfacing Arduino with KS0108 GLCD Video:
This example was tested with Arduino NANO in a DIY hardware circuit as shown in the video below:

Interfacing Arduino with KS0108 GLCD Proteus Simulation Video:
We can simulate this project using Proteus simulation software since it contains the KS0108 device simulation library. Simulation result for the Arduino UNO board with a 128×64 pixel KS0108 display is in the following video:

A simulation also for a 192×64 pixel display with Arduino MEGA board is shown in the video below:

Arduino with KS0108 GLCD Proteus simulation file download:
Proteus simulation file of the two above examples can be downloaded from the below Google Drive link. Use Proteus version 8.15 or higher to open it.

Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

4 thoughts on “Interfacing KS0108 Graphics LCD with Arduino”

  1. thanks for the great tutorial. I have a problem. the microcontroller I’m gonna use for a project is an stm32 with 3.3V working voltages, and this module works with 5V. I have 5V rail in my circuit, and I know I can go the voltage-translation way, but I’ve come to conclusion that I better (kinda have to) use a 74HC245 IC to translate my stm32 outputs of 3.3V to 5V required by GLCD. but this way I can only send data from MCU to GLCD. can’t read data from GLCD.

    so the question is : Do I need to read data from GLCD at all? (assuming I can program my MCU so that I know what’s currently shown on the LCD. can I get away with always sending data to LCD and never reading anything from it ?)

    1. I’m not 100% certain but I’m fairly confident the graphics library is write-only. It is hard to be certain as the R/W line is implemented but there seems to be a trend towards storing a bitmap in Microcontroller RAM and only ever writing to the display.

      Looking at the KS0108B datasheet on Sparkfun the device’s interface pins have lowered input thresholds compatible with 3.3V logic, so it does not need a buffer to raise the signals to 5V levels.

      In the other direction the STM32 might have a 5V tolerant port, it isn’t uncommon for some of a 3.3V microcontroller’s I/O to be 5V tolerant.

      Another possibility is that while the KS0108B is described as a 5V+/-10% part some other controllers like the nt7108 support 3.3v operation. 3.3V operation would avoid the need for another supply rail too.

      The most obvious clue is the display PCB has space for a second charge pump IC. On the 5V version one IC develops -5V on Vout, on the 3.3V version two charge pumps are used to develop -6.6V enabling contrast to be maintained. Contrast is set by the difference between VDD and VO regardless of the exact VDD value, a feature which is very useful when VDD is variable (battery projects).

  2. This is a fantastic guide on interfacing a KS0108 Graphics LCD with an Arduino! I appreciate the detailed explanation of the KS0108 controller and its features, as well as the step-by-step instructions for connecting the GLCD to the Arduino board.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top