What is the pinout of a 3.18 inch 128x64 COG LCD display?

By admin

If you’re working with a 3.18 inch 128x64 COG LCD display, the pinout is typically a 16-pin or 20-pin interface, depending on the specific controller (like the ST7565R or SSD1306-based variants). For the most common version using the ST7565R controller, the pinout is as follows: Pin 1 (VSS) is ground, Pin 2 (VDD) is 3.3V power supply, Pin 3 (V0) is for LCD bias voltage (often connected to a capacitor or resistor divider), Pin 4 (RS) is register select (data/command), Pin 5 (R/W) is read/write select (or tied to ground for write-only), Pin 6 (E) is enable signal, Pins 7 to 14 (DB0 to DB7) are the 8-bit parallel data bus, Pin 15 (CS) is chip select, and Pin 16 (RST) is reset. Some modules also include a backlight pin (LED+ and LED-), often on separate connectors. For a 3.18 inch 128x64 cog lcd display, the SPI interface variant uses a simplified 8-pin layout: Pin 1 (GND), Pin 2 (VCC), Pin 3 (SCLK), Pin 4 (MOSI), Pin 5 (DC), Pin 6 (RST), Pin 7 (CS), and Pin 8 (BL or backlight). Always verify with your datasheet, as pin order can vary between manufacturers like Winstar, Newhaven, or DisplayModule.

Let’s break down the pinout in more detail, because the exact pin assignments depend on the interface mode (parallel 6800, parallel 8080, SPI, or I2C). The ST7565R controller, which is widely used in these 3.18 inch 128x64 cog lcd display modules, supports multiple bus interfaces. The 16-pin interface is typical for 8-bit parallel mode, but many modern applications use SPI to reduce pin count. Here’s a table for the common 16-pin parallel interface (6800 mode):

Pin NumberSymbolDescriptionVoltage Level
1VSSGround (0V)0V
2VDDLogic power supply (2.7V to 3.6V, typical 3.3V)3.3V
3V0LCD bias voltage (negative voltage for contrast, typically -5V to -10V)-5V to -10V
4RSRegister select (0=command, 1=data)3.3V logic
5R/WRead/Write (0=write, 1=read; often tied to GND for write-only)3.3V logic
6EEnable signal (active high, used for data strobe)3.3V logic
7DB0Data bus bit 0 (LSB)3.3V logic
8DB1Data bus bit 13.3V logic
9DB2Data bus bit 23.3V logic
10DB3Data bus bit 33.3V logic
11DB4Data bus bit 43.3V logic
12DB5Data bus bit 53.3V logic
13DB6Data bus bit 63.3V logic
14DB7Data bus bit 7 (MSB)3.3V logic
15CSChip select (active low)3.3V logic
16RSTReset (active low)3.3V logic

For the 8080 parallel mode (common in Intel-style microcontrollers), the pinout is similar but the R/W pin is replaced by WR (write) and RD (read) signals. In that case, the 16-pin interface might have Pin 5 as WR and Pin 6 as RD, with E not used. But most 3.18 inch 128x64 COG LCDs default to 6800 mode, as the ST7565R has a pin (PS0, PS1) to select the interface. If you’re using the SPI variant, the pinout is much simpler. Here’s a table for the 8-pin SPI interface:

Pin NumberSymbolDescriptionVoltage Level
1GNDGround0V
2VCCPower supply (3.3V, but some modules tolerate 5V with regulator)3.3V
3SCLKSPI clock (up to 10 MHz typical)3.3V logic
4MOSISPI data input (master out slave in)3.3V logic
5DCData/Command (same as RS, 0=command, 1=data)3.3V logic
6RSTReset (active low)3.3V logic
7CSChip select (active low)3.3V logic
8BLBacklight (anode, typically 3.3V or 5V, with series resistor)3.3V or 5V

Now, let’s get into the nitty-gritty details. The COG (Chip-on-Glass) technology means the driver IC is bonded directly to the glass substrate, which reduces the module thickness to about 2.0 mm to 2.5 mm, including the PCB. The 3.18 inch diagonal size corresponds to a viewing area of approximately 70.0 mm x 40.0 mm (active area: 67.0 mm x 33.5 mm, with a dot pitch of 0.52 mm x 0.52 mm). The resolution is 128 columns by 64 rows, giving a total of 8,192 pixels. Each pixel is a monochrome STN (Super Twisted Nematic) or FSTN (Film Compensated STN) type, with a typical contrast ratio of 6:1 to 8:1, and a viewing angle of 60 degrees (left/right) and 40 degrees (up/down). The operating temperature range is -20°C to +70°C, and the storage range is -30°C to +80°C. The power consumption is about 1.5 mA to 3.0 mA for the logic (at 3.3V), and the backlight (if LED) draws 20 mA to 40 mA at 3.3V, depending on brightness.

The pinout matters because the V0 pin (Pin 3) is critical for adjusting the LCD contrast. The ST7565R generates a negative voltage internally using a charge pump, but you need an external capacitor (typically 1.0 µF to 10 µF) between V0 and VSS, and sometimes a resistor divider to set the bias level. The bias voltage is usually around -5V to -8V, but it varies with temperature. Some modules have a built-in potentiometer for contrast adjustment, but most require you to provide a voltage divider from VDD to V0. If you skip this, the display will show nothing or a faint ghost image. The RST pin is also crucial: it must be pulled high (to VDD) through a 10 kΩ resistor, and you need to hold it low for at least 1 µs after power-up to initialize the controller. The CS pin is active low, so you must drive it low to communicate; leaving it floating can cause bus contention.

For the parallel interface, the timing is strict. The ST7565R requires a minimum E pulse width of 200 ns for write cycles, and the data setup time is 100 ns before the rising edge of E. The read cycle is slower, with a 300 ns access time. If you’re using an 8-bit microcontroller like an Arduino Mega or STM32, you can drive the parallel bus at up to 8 MHz, but the LCD’s internal frame rate is limited to 60 Hz to 100 Hz. The SPI interface, on the other hand, can run at up to 10 MHz, and the data is sent MSB first. The DC pin must be set before the first clock cycle, and the CS pin must be low for the entire transaction. The SPI mode is typically Mode 0 (CPOL=0, CPHA=0) or Mode 3 (CPOL=1, CPHA=1), but the ST7565R datasheet specifies Mode 0 for most modules. You can check the datasheet for your specific module, but the common 3.18 inch 128x64 COG LCD from DisplayModule uses Mode 0.

Another detail: some modules include a BS0, BS1, BS2 pin configuration for interface selection. For example, if you have a 20-pin connector, the extra pins might be for these selection bits. The typical settings are: BS0=0, BS1=0, BS2=1 for 6800 parallel; BS0=1, BS1=0, BS2=1 for 8080 parallel; BS0=0, BS1=1, BS2=0 for SPI; and BS0=1, BS1=1, BS2=0 for I2C (though I2C is rare on these displays). The I2C interface uses a different pinout: SDA (data) and SCL (clock), with the address set by a hardware pin (usually 0x3C or 0x3D). But the 3.18 inch size is almost always parallel or SPI, because the pixel count is too high for I2C’s slow speed (400 kHz max).

The backlight pin (BL) is often a separate 2-pin connector (JST or Molex) on the module. The LED backlight is typically a white or blue LED array, with a forward voltage of 3.0V to 3.4V and a current of 20 mA to 30 mA per LED. If you connect it directly to 5V, you’ll burn out the LEDs, so you need a series resistor (e.g., 100 Ω for 3.3V supply, or 220 Ω for 5V supply). Some modules have a built-in resistor, but check the datasheet. The backlight brightness can be controlled by PWM on the BL pin, with a frequency of 1 kHz to 10 kHz.

Let’s talk about the physical connector. The 3.18 inch 128x64 COG LCD typically uses a 16-pin or 20-pin FPC (Flexible Printed Circuit) connector, with a pitch of 1.0 mm or 0.5 mm. The FPC is 0.3 mm thick and has a stiffener on the back. The pin 1 indicator is usually a small dot or a cutout on the FPC. When connecting to a breadboard, you’ll need an FPC-to-DIP adapter board, or you can solder wires directly to the pads. The pinout order is often printed on the back of the PCB, but it’s not always reliable. For example, some modules have the backlight pins on pins 15 and 16, instead of a separate connector. In that case, the pinout might be: Pin 1 (VSS), Pin 2 (VDD), Pin 3 (V0), Pin 4 (RS), Pin 5 (R/W), Pin 6 (E), Pin 7-14 (DB0-DB7), Pin 15 (LED+), Pin 16 (LED-). This is common on older modules from Winstar or Newhaven.

One more thing: the contrast adjustment via V0 is temperature-dependent. The ST7565R has a built-in temperature sensor, but it only compensates for the LCD’s response time, not the bias voltage. You can use a digital potentiometer (like the MCP41010) to adjust V0 dynamically, or you can use a fixed resistor divider. The typical value for R1 (between VDD and V0) is 10 kΩ, and R2 (between V0 and VSS) is 5 kΩ, but this varies. If you’re operating at 25°C, you might get a good contrast with a 10 kΩ pot. At 0°C, you might need to increase the bias voltage by 10% to 20%.

The reset circuit is also important. The RST pin is active low, and the ST7565R requires a reset pulse of at least 1 µs after power-up. If you’re using a microcontroller, you can control it via a GPIO. But if you’re using a simple circuit, you can connect RST to VDD through a 10 kΩ resistor and a 0.1 µF capacitor to ground, which creates a power-on reset delay of about 1 ms. This is sufficient for most cases. However, if you’re using the SPI interface, the reset sequence is critical: you must hold RST low for at least 10 µs, then release it, and wait 100 ms before sending commands. The ST7565R also has a software reset command (0xE2), but it’s not as reliable as a hardware reset.

Now, let’s look at the data bus in detail. In 8-bit parallel mode, the data is sent as a byte (DB0 to DB7). The command set for the ST7565R includes 0xAF (display on), 0xAE (display off), 0xA0 (segment remap), 0xC0 (common output scan direction), 0xA4 (normal display), 0xA5 (all pixels on), 0x2F (power control: booster, regulator, follower), 0x81 (set contrast), 0x40 (set display start line), and 0xB0 (set page address). The page address is from 0 to 7 (for 64 rows, each page is 8 rows). The column address is set by 0x10 (high nibble) and 0x00 (low nibble). For example, to write to the first pixel, you send: 0xAF (display on), 0x40 (start line 0), 0xB0 (page 0), 0x10 (column high nibble 0), 0x00 (column low nibble 0), then 0x01 (data byte for first 8 pixels). This is a common initialization sequence, but you need to wait 100 ms after power-up before sending commands.

The SPI interface uses a similar command set, but the data is sent as 8-bit bytes with the DC pin low for commands and high for data. The SPI clock speed should be limited to 10 MHz to avoid signal integrity issues. The CS pin must be toggled for each command or data byte, but some controllers allow you to keep CS low for multiple bytes. The ST7565R does not support daisy-chaining, so each display needs its own CS pin. The MISO pin is not used, because the display is write-only (unless you’re reading the status register, which is rare).

Let’s talk about power supply. The VDD pin is for the logic, and it must be between 2.7V and 3.6V. If you’re using a 5V microcontroller, you need a level shifter for the data pins, or you can use a 3.3V regulator (like the AMS1117-3.3) to power the display. The V0 pin is for the