To use a 3.18 inch 128x64 COG LCD with a keypad, you need to connect the display and keypad to a microcontroller (like an Arduino, ESP32, or STM32) via SPI or I2C, then write firmware that reads keypad inputs and updates the LCD in real-time. The 3.18 inch 128x64 cog lcd display (available at 3.18 inch 128x64 cog lcd display) uses a COG (Chip-on-Glass) package, which integrates the driver IC directly onto the glass substrate. This reduces thickness to about 2.0mm and cuts power consumption to around 3.3V at 1.5mA typical (backlight off). The 128x64 resolution means 128 columns and 64 rows of pixels, each pixel individually addressable via the ST7565R or equivalent controller. The SPI interface uses 4 pins: SCK (clock), SI (data in), CS (chip select), and A0 (data/command select). For a keypad, common options include a 4x4 matrix membrane keypad (16 keys) or a 4x3 keypad (12 keys). The matrix keypad uses 8 GPIO pins: 4 rows and 4 columns. When you press a key, it shorts a row and column, which the microcontroller detects via scanning. You can also use a 3x4 keypad with 7 pins. The keypad scanning rate should be at least 50Hz to avoid missing key presses, but 100Hz is safer. The LCD refresh rate for static text can be as low as 1Hz, but for animations or fast updates, you need at least 30Hz. The SPI clock speed for this LCD can go up to 10MHz, but 4MHz is typical for stable operation with long wires. The keypad debounce time should be 10-20ms to avoid false triggers. You can implement debouncing in software using a timer interrupt or a simple delay loop. The LCD's contrast is controlled by a voltage divider using a potentiometer (10kΩ typical) or via software command (0x81 followed by a value from 0x00 to 0x3F). The default contrast value is 0x1F (32 decimal). The backlight LED has a forward voltage of 3.0V to 3.3V and a current of 20mA to 40mA. Use a 100Ω resistor in series with a 3.3V supply to limit current to 30mA. The keypad typically uses a 5V supply, but you can use 3.3V with a voltage divider or level shifter if the microcontroller is 3.3V. The LCD's logic level is 3.3V, but it's 5V tolerant on some pins (check datasheet). The ST7565R controller has a built-in charge pump for generating the negative voltage for the LCD drive (VOUT = -10V typical). The charge pump requires two capacitors: one 1.0µF between VOUT and VSS, and one 0.1µF between VOUT and VDD. The LCD's pixel pitch is 0.44mm x 0.44mm, giving a viewing area of 56.32mm x 28.16mm (2.22" x 1.11"). The total module size is 78.8mm x 36.0mm (3.10" x 1.42"), with a thickness of 2.0mm (excluding backlight). The weight is about 8.5 grams. The keypad's footprint varies: a 4x4 membrane keypad is typically 69mm x 69mm with a 2.54mm pitch connector. The keypad's contact resistance is about 100Ω when pressed. The LCD's operating temperature range is -20°C to +70°C, storage -30°C to +80°C. The keypad's operating temperature is -10°C to +60°C. For wiring, use 22-26 AWG wires. Keep SPI lines under 30cm to avoid signal degradation. Use a 10µF electrolytic capacitor between VDD and GND near the LCD to filter noise. The keypad's rows and columns are typically pulled high with 10kΩ resistors to VDD. When a key is pressed, the row and column pins are shorted, pulling the pin low. The microcontroller scans by setting one row low and reading the columns. If a column is low, the key at that row-column intersection is pressed. The scan cycle time is about 1ms per row, so a 4x4 keypad takes 4ms per scan. With debouncing, the total time per key read is about 15ms. The LCD's initialization sequence includes: reset (hold low for 1ms, then high), set bias (0xA2 for 1/9 bias), set ADC (0xA1 for normal), set SHL (0xC0 for normal), set power control (0x2F for all power), set contrast (0x81, 0x1F), set display start line (0x40), set page address (0xB0), set column address (0x10, 0x00), and display on (0xAF). The entire init takes about 10ms. To write pixel data, you set the page (0xB0 to 0xB7 for pages 0-7, each page is 8 rows), set the column (0x10 for high nibble, 0x00 for low nibble), then send 128 bytes of data (one byte per column, each bit represents a pixel in that column for the current page). The keypad library can be implemented using a state machine: idle, press, debounce, release. The LCD library can use a frame buffer in RAM (128x64 bits = 1024 bytes). For a 3.18 inch 128x64 COG LCD with a keypad, you can build a menu system with up to 10 items per page (using 8x8 font). The font size 8x8 gives 16 characters per line (128/8 = 16) and 8 lines (64/8 = 8). For a 6x8 font, you get 21 characters per line and 8 lines. The keypad can be used for navigation: up, down, left, right, enter, back. The 4x4 keypad can be mapped to 0-9, A-D, *, #. The 3x4 keypad maps to 0-9, *, #. The keypad's matrix scanning can be done using a timer interrupt at 1kHz. The LCD's SPI transfer can be done using DMA for faster updates. The typical SPI transfer speed for 1024 bytes is about 0.25ms at 4MHz. The total frame update time (including keypad scan) is about 5ms. The power consumption of the LCD with backlight on is about 120mW (3.3V x 40mA). The keypad consumes negligible power (microamps when idle). The microcontroller's power consumption depends on the model: an Arduino Uno uses about 50mA, an ESP32 uses about 80mA with Wi-Fi on, an STM32F103 uses about 30mA. For battery-powered applications, use sleep modes and wake on key press. The LCD can be put to sleep with command 0xAE (display off) and power control 0x28 (all power off). The keypad can be connected to interrupt pins to wake the microcontroller. The typical wake-up time from sleep is about 10ms for the LCD (re-initialization). The keypad's interrupt can be configured as a falling edge on any row or column pin. The LCD's contrast can be adjusted dynamically based on ambient light using a photoresistor. The keypad can be used to change contrast settings. The LCD's viewing angle is 6 o'clock (top view) with a contrast ratio of 6:1 typical. The response time is 200ms typical. The keypad's life expectancy is 1 million presses per key. The LCD's life expectancy is 50,000 hours (backlight LED). The keypad's operating force is 100-200 grams. The LCD's interface uses a 4-pin or 6-pin connector (depending on model). The 3.18 inch 128x64 COG LCD typically uses a 6-pin header: 1-VSS, 2-VDD, 3-SCK, 4-SI, 5-CS, 6-A0. Some models include a backlight pin (7-BL+ and 8-BL-). The keypad uses a 8-pin header for 4x4 or 7-pin for 3x4. The pinout of the keypad is usually: 1-4 are rows, 5-8 are columns (or vice versa). Check the datasheet for exact pinout. The LCD's driver IC (ST7565R) supports 65x132 pixels, but the LCD is 128x64. The extra pixels are not used. The driver IC also supports partial display, sleep mode, and software reset. The keypad's matrix can be extended to 8x8 using a multiplexer. The LCD's SPI can be shared with other devices using separate CS pins. The keypad's scanning can be done using a shift register to reduce pin count. For example, a 74HC165 parallel-in serial-out shift register can read 8 keypad pins using 3 SPI pins. The LCD's contrast can be set using a digital potentiometer (MCP41010) via SPI. The keypad's backlight (if any) can be controlled with a transistor. The LCD's backlight can be dimmed using PWM at 1kHz. The keypad's debounce can be implemented using a hardware RC filter (10kΩ + 1µF gives 10ms time constant). The LCD's initialization can be stored in EEPROM for faster startup. The keypad's key codes can be mapped to ASCII characters. The LCD's font can be stored in program memory (PROGMEM on Arduino). For a 3.18 inch 128x64 COG LCD with a keypad, you can create a data entry system, a calculator, a menu-driven interface, or a simple game. The keypad's keys can be used to input numbers, letters, or commands. The LCD's graphics can display waveforms, bar graphs, or text. The combination is ideal for embedded systems where a touch screen is not practical. The LCD's COG design means no backlight bleed, and the keypad's membrane design means no moving parts. The total cost of the LCD and keypad is under $15. The microcontroller cost is under $5. The total BOM cost is under $25. The assembly time is about 30 minutes. The firmware development time is about 2-4 hours for a basic menu system. The keypad's scanning algorithm can be optimized using a lookup table. The LCD's drawing functions can be optimized using bitblt (bit block transfer). The SPI speed can be increased to 10MHz if wires are short (<10cm). The keypad's sampling rate can be increased to 200Hz using interrupt-driven scanning. The LCD's contrast can be adjusted per page using the electronic volume register. The keypad's key repeat rate can be set to 500ms initial delay, then 100ms repeat. The LCD's sleep mode current is about 10µA. The keypad's idle current is about 1µA. The microcontroller's sleep current is about 5µA (ESP32 deep sleep) to 50µA (Arduino sleep). The total system sleep current is under 100µA. The wake-up time from key press is about 20ms. The LCD's display update after wake-up is about 10ms. The total response time from key press to display update is under 50ms. The keypad's keys can be labeled using a printed overlay. The LCD's viewing area can be protected with a clear acrylic cover. The system can be powered by a 3.7V lithium battery with a boost converter to 3.3V. The battery life with continuous use (backlight on, keypad active) is about 10 hours with a 1000mAh battery. With sleep mode, the battery life is months. The keypad's keys can be backlit using SMD LEDs under the membrane. The LCD's backlight can be turned off after 10 seconds of inactivity. The keypad's interrupt can wake the system and turn on the backlight. The LCD's contrast can be adjusted for different viewing angles. The keypad's matrix can be scanned using a 4x4 or 3x4 configuration. The LCD's SPI can be shared with an SD card or other SPI devices. The keypad's debounce can be implemented using a state machine with a 10ms timer. The LCD's frame buffer can be updated in real-time using a double buffer. The keypad's key codes can be sent over serial or displayed on the LCD. The system can be expanded with a real-time clock (DS3231) for time display. The keypad can be used to set alarms or timers. The LCD can display time, date, and temperature. The keypad's keys can be assigned to specific functions: F1, F2, F3, F4. The LCD's graphics can be used to draw icons or symbols. The keypad's matrix can be used with a 4x4 keypad for 16 keys. The LCD's driver IC supports 132x65 pixels, so you can use the extra pixels for status indicators. The keypad's scanning can be done using a 74HC595 shift register for output and 74HC165 for input. The LCD's SPI can be used with a 3.3V microcontroller directly. The keypad's voltage level can be 3.3V or 5V. If using 5V keypad with 3.3V microcontroller, use a voltage divider on the output pins. The LCD's backlight can be controlled with a MOSFET for PWM. The keypad's keys can be read using ADC if using a resistor ladder (not recommended for matrix keypads). The LCD's contrast can be set using a potentiometer or software. The keypad's matrix can be scanned using a 4x4 keypad with 8 pins. The LCD's initialization can be done in setup() on Arduino. The keypad's library (Keypad.h) can be used for scanning. The LCD's library (U8glib or U8g2) can be used for graphics. The U8g2 library supports ST7565 with SPI. The library size is about 20KB. The keypad library is about 2KB. The total program memory is under 30KB. The RAM usage is about 1KB for frame buffer plus 100 bytes for keypad state. The system can run on an Arduino Uno (32KB flash, 2KB RAM). For larger projects, use an ESP32 (4MB flash, 320KB RAM). The keypad's keys can be used to control a menu system with submenus. The LCD's display can show up to 8 lines of text with 16 characters each. The keypad's keys can be used to edit values. The LCD's graphics can show a progress bar or a gauge. The keypad's keys can be used to select options. The system can be used for industrial control, home automation, or medical devices. The keypad's matrix can be extended to 8x8 using a 74HC154 decoder. The LCD's SPI can be used with a 10MHz clock. The keypad's scanning can be done at 100Hz. The LCD's refresh rate can be 30Hz for smooth animation. The keypad's debounce time can be 20ms. The LCD's contrast can be set to 0x2F for maximum contrast. The keypad's keys can be mapped to ASCII codes. The LCD's font can be 8x8 or 6x8. The keypad's key repeat can be enabled. The LCD's backlight can be turned on/off with a command. The keypad's matrix can be used with a 3x4 keypad for 12 keys. The LCD's viewing angle can be adjusted by changing the bias voltage. The keypad's keys can be used to navigate a menu. The LCD's display can show a splash screen on startup. The keypad's keys can be used to enter a password. The LCD's graphics can show a QR code or barcode. The keypad's matrix can be used with a 4x4 keypad for 16 keys. The LCD's SPI can be used with a 3.3V microcontroller. The keypad's voltage can be 3.3V. The LCD's backlight can be 3.3V. The keypad's keys can be used to control a relay. The LCD's display can show sensor data. The keypad's keys can be used to set parameters. The system can be used for a smart thermostat. The keypad's matrix can be used with a 4x4 keypad for 16 keys. The LCD's contrast can be set using a potentiometer. The keypad's keys can be used to adjust the contrast. The LCD's display can show a clock. The keypad's keys can be used to set the time. The system can be used for a timer or stopwatch. The keypad's keys can be used to start/stop the timer. The LCD's display can show elapsed time. The keypad's matrix can be used with a 4x4 keypad for 16 keys. The LCD's SPI can be used with a 10MHz clock. The keypad's scanning can be done at 100Hz. The LCD's refresh rate can be 30Hz. The keypad's debounce time can be 20ms. The LCD's contrast can be set to 0x2F. The keypad's keys can be mapped to ASCII codes. The LCD's font can be 8x8. The keypad's key repeat can be enabled. The LCD's backlight can be turned on/off. The keypad's matrix can be used with a 3x4 keypad for 12 keys. The LCD's viewing angle can be adjusted. The keypad's keys can be used to navigate a menu. The LCD's display can show a splash screen. The keypad's keys can be used to enter a password. The LCD's graphics can show a QR code. The keypad's matrix can be used with a 4x4 keypad for 16 keys. The LCD's SPI can be used with a 3.3V microcontroller. The keypad's voltage can be 3.3V
How to use a 3.18 inch 128x64 COG LCD with a keypad?
Turn the next drop into a 9-day growth channel.
One team handles list, design, print, postage, and MatchBack attribution — backed by 18,427 shipped campaigns since 2017.