What is the pinout of a 128x32 COG LCD display?

By admin

If you’re working with a 128x32 COG (Chip-On-Glass) LCD display, the pinout is your first roadblock—and it’s surprisingly straightforward once you know the numbers. Most common modules, like the one from Newhaven Display or Winstar, use a 14-pin or 16-pin interface, with variations depending on whether you’re running SPI, I2C, or parallel. For the standard SPI version, which is what you’ll find in the 128x32 cog lcd display from DisplayModule, the pinout typically includes: VSS (ground), VDD (3.3V or 5V, depending on the module), V0 (contrast adjustment, often tied to a potentiometer or a negative voltage generator), RS (register select, sometimes called DC for data/command), R/W (read/write, but for SPI it’s usually tied low or left floating), E (enable, or chip select in SPI mode), DB0-DB7 (data lines, but only DB4-DB7 are used in 4-bit parallel mode), and backlight pins (LED+ and LED-). For SPI, you’ll see SCK (serial clock), SDA (serial data), CS (chip select), and sometimes a reset pin. The exact pinout varies by manufacturer, so always check the datasheet—but the 14-pin SPI layout is your safest bet for hobbyist projects.

Let’s break this down with real numbers. A typical 128x32 COG LCD, like the ST7565R-based module, runs at 3.3V logic, but can handle 5V on VDD with a voltage regulator. The pinout for the 14-pin SPI variant is: pin 1 (VSS, ground), pin 2 (VDD, 3.3V), pin 3 (V0, contrast, often -2V to -5V via a charge pump), pin 4 (RS, or DC, for data/command selection), pin 5 (R/W, but for SPI, it’s usually tied to VSS or left unconnected), pin 6 (E, or CS, active low), pin 7 (DB0, but for SPI, it’s the serial data line SDA), pin 8 (DB1, sometimes used as SCK), pin 9 (DB2, not used in SPI, often left floating), pin 10 (DB3, not used), pin 11 (DB4, not used), pin 12 (DB5, not used), pin 13 (DB6, not used), pin 14 (DB7, not used). Wait—that’s misleading. In reality, SPI modules multiplex the data lines: DB0 becomes SDA, DB1 becomes SCK, and DB2-DB7 are often unused or repurposed for backlight control. For the 16-pin version, you add two backlight pins (LED+ and LED-), and sometimes a reset pin (RST, active low). The contrast pin (V0) is critical: if you don’t provide a negative voltage, the display will be blank. Many modules include an internal charge pump, so you just need a capacitor between V0 and VOUT (pin 3 and pin 4 on some controllers).

Now, let’s get into the weeds with a specific example: the UG-2864HSWEG01, a 128x32 COG OLED (but similar pinout). It uses a 14-pin interface with SPI: pin 1 (VSS), pin 2 (VDD), pin 3 (V0, for OLED, it’s internal, so no contrast pin), pin 4 (DC, data/command), pin 5 (R/W, tied low), pin 6 (CS, chip select), pin 7 (SCLK, serial clock), pin 8 (SDIN, serial data), pin 9 (BS1, for interface selection, often tied to VDD for SPI), pin 10 (BS2, tied to VSS for SPI), pin 11 (RST, reset), pin 12 (VCC, for OLED, it’s 3.3V), pin 13 (VCOMH, for OLED, internal), pin 14 (VSS). For LCD, the BS1 and BS2 pins are replaced by DB0-DB7. The key difference: COG LCDs have a glass substrate with the driver IC bonded directly, so the pinout is often standardized to 14 pins for 128x32 resolution. The ST7565R controller, for example, uses a 16-pin interface for 8-bit parallel, but for SPI, you only need 6 pins: VDD, VSS, CS, DC, SCK, SDA. The rest are either tied to VDD/VSS or left floating.

Here’s a table to clarify the common pinout for a 128x32 COG LCD with SPI, based on the Newhaven Display NHD-0216K1Z-NSW-BBW-V3 (similar to 128x32 but with 16x2 characters—the pinout logic is identical for graphic modules):

Pin Number Symbol Function Notes
1 VSS Ground 0V, connect to power supply ground
2 VDD Power supply 3.3V or 5V, depending on module; check datasheet
3 V0 Contrast voltage Negative voltage (e.g., -2V to -5V) for LCD; often tied to a potentiometer or internal charge pump
4 RS (DC) Register select / Data/Command High for data, low for command; used in SPI mode
5 R/W Read/Write For SPI, tie to VSS (write-only) or leave floating; not used in 4-wire SPI
6 E (CS) Enable / Chip select Active low; used in SPI mode as chip select
7 DB0 (SDA) Data bit 0 / Serial data In SPI mode, this is the serial data input (SDA or MOSI)
8 DB1 (SCK) Data bit 1 / Serial clock In SPI mode, this is the serial clock (SCLK)
9 DB2 Data bit 2 Not used in SPI; tie to VSS or leave floating
10 DB3 Data bit 3 Not used in SPI; tie to VSS or leave floating
11 DB4 Data bit 4 Not used in SPI; tie to VSS or leave floating
12 DB5 Data bit 5 Not used in SPI; tie to VSS or leave floating
13 DB6 Data bit 6 Not used in SPI; tie to VSS or leave floating
14 DB7 Data bit 7 Not used in SPI; tie to VSS or leave floating
15 LED+ Backlight anode Typically 3.3V or 5V via a resistor (e.g., 100 ohms for 20mA)
16 LED- Backlight cathode Ground

But here’s the catch: not all modules use this exact pinout. For example, the Winstar WO12832A uses a 14-pin interface with a different order: pin 1 (VSS), pin 2 (VDD), pin 3 (V0), pin 4 (RS), pin 5 (R/W), pin 6 (E), pin 7 (DB0), pin 8 (DB1), pin 9 (DB2), pin 10 (DB3), pin 11 (DB4), pin 12 (DB5), pin 13 (DB6), pin 14 (DB7), and no backlight pins—the backlight is separate. For SPI, you need to set the interface select pins (BS1, BS2) on the controller. On the ST7565R, BS1 and BS2 are pins 9 and 10 on the IC, but on the module, they’re often tied to VDD or VSS via resistors. For SPI mode, BS1=1 (VDD) and BS2=0 (VSS) for 4-wire SPI, or BS1=0 and BS2=0 for 3-wire SPI. The 3-wire SPI uses only SDA, SCK, and CS, with no DC pin—the data/command bit is embedded in the first byte. This is common in OLEDs but rare in COG LCDs.

Let’s talk about voltage levels. The 128x32 COG LCD typically operates at 3.3V logic, but the backlight can be 5V. The contrast pin V0 requires a negative voltage, which is generated internally by a charge pump (like the ST7565R’s built-in DC-DC converter). You’ll see a capacitor between V0 and VOUT (pin 3 and pin 4 on the IC, but on the module, it’s often a 1uF or 10uF capacitor). If you don’t provide this, the display will show nothing. For example, the Newhaven Display NHD-0216K1Z-NSW-BBW-V3 (16x2 character LCD, but similar COG technology) uses a 10uF capacitor between V0 and VOUT. For 128x32 graphic modules, the same applies. The datasheet for the ST7565R specifies a typical contrast voltage of -4.5V at 3.3V VDD, with a tolerance of ±0.5V. You can adjust this with a potentiometer between V0 and VDD, or use a fixed resistor divider. But many modules have an internal voltage regulator, so you just need to set the contrast via software (e.g., sending command 0x81 followed by a value from 0x00 to 0x3F).

Now, let’s look at a real-world example: the DisplayModule 128x32 COG LCD with SPI. The pinout is: pin 1 (VSS), pin 2 (VDD, 3.3V), pin 3 (V0, contrast), pin 4 (DC, data/command), pin 5 (R/W, tied low), pin 6 (CS, chip select), pin 7 (SDA, serial data), pin 8 (SCK, serial clock), pin 9 (RST, reset), pin 10 (BS1, tied to VDD for SPI), pin 11 (BS2, tied to VSS for SPI), pin 12 (VCC, 3.3V for logic), pin 13 (VCOMH, for LCD, internal), pin 14 (VSS). The backlight pins are separate: LED+ and LED- on a 2-pin header. The module uses the ST7565R controller, which supports 4-wire SPI at up to 10 MHz. The command set includes: 0xAF (display on), 0xAE (display off), 0xA4 (display all points on), 0xA5 (display all points off), 0xA6 (normal display), 0xA7 (reverse display), 0x40 (set display start line), 0xB0 (set page address), 0x10 (set column address high nibble), 0x00 (set column address low nibble). The resolution is 128 columns by 32 rows, but the controller has 128x64 memory, so you need to set the page address to 0xB0 (page 0) to 0xB3 (page 3) for the top 32 rows. The bottom 32 rows are unused.

Here’s a table of the command set for the ST7565R, which is the most common controller for 128x32 COG LCDs:

Command Hex Code Function Notes
Display ON 0xAF Turn on the display After initialization
Display OFF 0xAE Turn off the display Power saving mode
Set Display Start Line 0x40-0x7F Set the first line of the display 0x40 is line 0; 0x7F is line 63
Set Page Address 0xB0-0xB7 Set the page (row) for memory access 0xB0 is page 0; 0xB7 is page 7; for 128x32, use 0xB0-0xB3
Set Column Address High 0x10-0x1F Set the high nibble of the column address 0x10 is column 0; 0x1F is column 15
Set Column Address Low 0x00-0x0F Set the low nibble of the column address 0x00 is column 0; 0x0F is column 15
Set Contrast 0x81 Set the contrast level Followed by a byte (0x00-0x3F)
Set Power Control 0x2F Enable internal charge pump 0x2F enables all: booster, regulator, follower
Set Segment Re-map 0xA0 / 0xA1 Reverse column order 0xA0 is normal; 0xA1 is reversed
Set COM Output Scan Direction 0xC0 / 0xC8 Reverse row order 0xC0 is normal; 0xC8 is reversed

Now, let’s talk about the physical pinout. The 128x32 COG LCD has a glass substrate with a 0.1-inch pitch connector (2.54mm), but some modules use a 0.05-inch pitch (1.27mm) or even a flexible flat cable (FFC) with 0.5mm pitch. For example, the Winstar WO12832A uses a 14-pin single-row header with 2.54mm pitch, while the Newhaven Display NHD-12832A uses a 16-pin FFC with 0.5mm pitch. The pinout for the FFC version is: pin 1 (VSS), pin 2 (VDD), pin 3 (V0), pin 4 (RS), pin 5 (R