Arduino GLCD Library: KS0108 Family

# KS0108 Family

The KS0108 is a popular controller chip used in GLCD displays but the wiring for these panels is not standardized and it is important to check the datasheet for your panel to confirm how it should be wired. Incorrect connections of the signal lines are the most common cause of problems.

Warning:
  Particular care should be taken with the power leads as wiring these incorrectly can destroy a panel.

Most GLCD panels require an external preset pot to set the LCD working voltage (contrast) and a fixed resistor to limit the current in the backlight. The datasheet for your panel should provide specific information on the wiring and choice of components for this.

The table below shows common pinouts for KS0108 panels. The numbers under the Arduino column are the Arduino pins used in the configuration file provided in the download, if you alter the wiring to Arduino pins then you must change the pin assignments in the configuration file.

The numbers in the Panel A/B/C columns are the pin numbers of the GLCD display panel

KS0108 Pin Connections Table
Ardiuno pins | Mega | Sanguino | Teensy | Teensy ++ | GLCD Function | Panel A | Panel B | Panel C | Comments
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
5V | 5V | 5V | 5V | 5V | +5 volts | 1 | 2 | 13 |
Gnd | Gnd | Gnd | Gnd | Gnd | GND | 2 | 1 | 14 |
n/a | n/a | n/a | n/a | n/a | Contrast in | 3 | 3 | 12 | Wiper of contrast pot
8 | 22 | 0 | 0 | 10 | D0 | 4 | 7 | 1 |
9 | 23 | 1 | 1 | 11 | D1 | 5 | 8 | 2 |
10 | 24 | 2 | 2 | 12 | D2 | 6 | 9 | 3 |
11 | 25 | 3 | 3 | 13 | D3 | 7 | 10 | 4 |
4 | 26 | 4 | 13 | 14 | D4 | 8 | 11 | 5 |
5 | 27 | 5 | 14 | 15 | D5 | 9 | 12 | 6 |
6 | 28 | 6 | 15 | 16 | D6 | 10 | 13 | 7 |
7 | 29 | 7 | 4 | 17 | D7 | 11 | 14 | 8 |
14 (alog 0) | 33 | 24 | 7 | 18 | CSEL1 | 12 | 15 | 15 | Chip 1 select
15 (alog 1) | 34 | 25 | 8 | 19 | CSEL2 | 13 | 16 | 16 | Chip 2 select
Reset |  |  |  |  | Reset | 14 | 17 | 18 | Connect to reset
16 (alog 2) | 35 | 26 | 6 | 8 | R_W | 15 | 5 | 10 | Read/write
17 (alog 3) | 36 | 27 | 5 | 9 | D_I | 16 | 4 | 11 | Data/Instruction (RS)
18 (alog 4) | 37 | 28 | 9 | 7 | EN | 17 | 6 | 9 | Enable
n/a | n/a | n/a | n/a | n/a | Contrast out | 18 | 18 | 17 | 10k or 20k preset
n/a | n/a | n/a | n/a | n/a | Backlight +5 | 19 | 19 | 19 | See datasheet
Gnd | Gnd | Gnd | Gnd | Gnd | Backlight Gnd | 20 | 20 | 20 | See datasheet

The following illustrations show the wiring for these panel types with a standard Arduino (168/328). Although the pin number on the GLCD panels are different, the corresponding functions are connected to the same Arduino pins in all three examples so the supplied ks0108_Config.h configuration file should work without change if you wire your panel following the appropriate diagram. The ks0108 needs to have its reset pin taken low for a brief period after power is applied. The diagrams show the display’s reset pin connected to the Arduino reset pin and this will automatically reset the display when the Arduino resets. You can also wire the display reset pin to a spare Arduino pin and control reset in software by adding a define to the panel configuration file (see configuration below), but this is only necessary if the display reset is not wired to Arduino reset.

Note:
  The diagrams that follow are for standard Arduino boards (ATmega 168/328). If you have a different board then you should follow the pin assignments in the Pin Connections Table above.

A tip for making the physical connections is use a small piece of stripboard with header pins for 5V, ground and Reset providing connection to the Arduino. The picture has an example layout for a type A panel

Mega, Sanguino and Teensy boards provide faster performance by allowing all the data pins to be connected to the same port. Configuration files for these boards are provided in the library and note that each board type uses a different selection of pins.