Arduino openGLCD Library Version v1.0rc2 |

All Classes Functions Variables Enumerations Enumerator Groups Pages
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. Also, it as odd as it sounds ensure that the display is actually a KS0108 display.

Warning
  Particular care should be taken with the power leads and Vee/Vout as wiring these incorrectly can destroy a panel.

Most GLCD panels require an external potiometer 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. It is important to note that ks0108 modules do not wire up their contrast pot the same way as a typical hd44780 character lcd. A hd44780 lcd typically hooks its contrast pot legs to +5v and GND. In most cases, on a ks0108, the pot, which is typically between 10-20k, is used to create a varying negative voltage from Vee up to GND that is used to feed to the Vo input signal. In order to do this, one leg of the pot needs to hook to ground, one leg needs to hook to the Vee negative voltage output pin and then the wiper, which is the middle pin of the pot, will have the variable voltage output that can be fed to the Vo contrast control input pin.

The table below summarizes how to wire up the GLCD module. A KS0108 GLCD module will have 20 pins as indicated in the "Pin Function" column. Notice that there are no GLCD module pin numbers in the table. This is because pin locations for the functions is not standardized. The datasheet for the specific GLCD must be consulted to know which function has been connected to which GLCD pin number. Pay close attention to the signals in the table.

Warning
  It is important to verify that the display is really a KS0108 based module not some other type of display. While a ST7920 display will have a very similar pinout, a KS0108 glcd uses chip select lines whereas the ST7920 does not. Typically a ST7920 will have two pins labled PSB (parallel/serial select) and NC (not connected). Do not attempt to wire up a ST7920 as if it were a ks0108 attempting to use the PSB and NC pins as if they were chip select lines. Doing so could potentially damage the display or the Arduino.

KS0108 Pin Function Table
KS0108 Pin Function | Comment
--- | ---
GND | Connect to GND
+5 volts | Connect to +5v
(Vo) Contrast in | Connect to Wiper (middle pin) of contrast pot
D_I | Data/Instruction (RS) (see mapping table below)
R_W | Read/write (see mapping table below)
EN | Enable (see mapping table below)
D0 | Data Bit 0 (see mapping table below)
D1 | Data bit 1 (see mapping table below)
D2 | Data bit 2 (see mapping table below)
D3 | Data bit 3 (see mapping table below)
D4 | Data bit 4 (see mapping table below)
D5 | Data bit 5 (see mapping table below)
D6 | Data bit 6 (see mapping table below)
D7 | Data bit 7 (see mapping table below)
CSEL1 | Chip 1 select (see mapping table below)
CSEL2 | Chip 2 select (see mapping table below)
Reset in | Connect to +5v
(Vee/Vout) Contrast out | connect to 1 leg of Contrast pot
Backlight Anode | +5v (See datasheet for resistor value)
Backlight Cathode | GND
| connect 1 leg of contrast pot to GND

The table below shows the Arduino pin to KS0108 Pin Function assignments for each Arduino board type. Each row represents the Arduino pin connections for the board type as indicated by the Board Type column. The columns to the right of the Board Type represent KS0108 pin functions.
For example:
Uno analog pin A3 is connected to the GLCD pin function D_I.
Uno digital pin 8 is connected to the GLCD pin function D0 (data bit 0)
Teensy 3.0 pin 3 is connected to the GLCD pin function CSEL1 (chip select 1) - See important Teensy 3.0 warning below

Arduino pin to KS0108 Pin Function mapping Table
Board Type | D_I | R_W | EN | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | CSEL1 | CSEL2 | CSEL3*
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
Uno | A3 | A2 | A4 | 8 | 9 | 10 | 11 | 4 | 5 | 6 | 7 | A0 | A1 | 3*
Leonardo | A3 | A2 | A4 | 8 | 9 | 10 | 11 | 4 | 5 | 6 | 7 | A0 | A1 | 3*
Mega | 36 | 35 | 37 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 32*
Teensy 2.0 | 5 | 6 | 9 | 0 | 1 | 2 | 3 | 13 | 14 | 15 | 4 | 7 | 8 | (no default)*
Teensy ++ 2.0 | 9 | 8 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | (no default)*
Teensy 3.0/3.1/LC | 9* | 8* | 7* | 16* | 17* | 18* | 19* | 20* | 21* | 22* | 23* | 3* | 2* | (no default)*
Mighty1284p | 27 | 26 | 28 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 29*
Sanguino | 27 | 26 | 28 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 29*
Bobuino | A3 | A2 | A4 | 8 | 9 | 10 | 11 | 4 | 5 | 6 | 7 | A0 | A1 | 3*
SleepingBeauty | A3 | A2 | A4 | 8 | 9 | 10 | 11 | 4 | 5 | 6 | 7 | A0 | A1 | 3*
chipKIT | A3 | A2 | A4 | 8 | 9 | 10 | 11 | 4 | 5 | 6 | 7 | A0 | A1 | 3*
DUE (NOT SUPPORTED) | - | - | - | - | - | - | - | - | - | - | - | - | - | -

Note

  ## CSEL3

CSEL3 is only used on some 192x64 displays

Warning

  ## Teensy 3.0 and Teensy LC pins must NEVER be connected directly to the GLCD module data pins.

  This is because the GLCD is 5v while the Teensy 3.0 and LC are 3v and not 5v tolerant. The voltages must be mapped using a voltage level shifter in order to avoid damaging the Teensy 3.0/LC. The voltage level shifter must be bi-directional on the 8 bit data lines. Alternatively, each connection from Teensy 3.0/LC to the GLCD can be protected by going go through a 10k resistor in series.
  i.e. [Teensy 3.0/LC pin]<— 10k Resistor (Brown/Black/Orange) —>[GLCD pin]
  Note: With the Teensy LC, you must also enable the read cache (config file symbol GLCDCFG_READ_CACHE) as the LC is unable to reliably read the data lines through the series resistors. The read cache will offer a considerable performance increase but will consume 1 bit of ram per pixel or 1k for a 128x64 glcd.

Mega, Mighty1284p, Sanguino, and Teensy boards provide faster performance by allowing all the data pins to be connected to the same port. The configuration files for these boards provided in the library have the data pins assigned to take advantage of this additional performance capability.

Note
  links to the Mighty1284p core code can be found in the Additional Resources section.