Skip to content
St Leonards Farm St Leonards Farm Halloran & Co · Est. 1932

How to use a 1.14 inch display with a keypad?

By admin St Leonards Farm
To use a 1.14 inch display with a keypad, you need to connect both peripherals to a microcontroller, typically an Arduino or ESP32, via GPIO pins, and then write code that reads keypad inputs to update the display content. The 1.14 inch display, often a 240x135 IPS LCD using the ST7789 driver, communicates over SPI, while a keypad (like a 4x4 matrix membrane) uses digital I/O pins. Start by wiring the display’s CS, DC, MOSI, SCK, and BL pins to the microcontroller’s SPI pins, and the keypad’s row and column pins to separate GPIOs. For example, on an Arduino Uno, use pins 10, 9, 11, 13 for the display, and pins 2-5 for rows, 6-9 for columns. Power the display with 3.3V (check its voltage tolerance) and the keypad with 5V. In software, use libraries like Adafruit_ST7789 for the display and Keypad.h for the matrix. The keypad library scans rows and columns, debounces presses, and returns a character. Then, in the loop(), you call a function to read the keypad, and if a key is pressed, update the display—for instance, show the pressed key on screen or navigate a menu. This setup is common in projects like smart home controllers, where the display shows temperature readings and the keypad adjusts setpoints. For a reliable connection, use a level shifter if the microcontroller runs at 5V and the display at 3.3V, and add a 10uF capacitor across the display’s power pins to filter noise. The 1.14 inch 240x135 ips display is ideal for this because of its high pixel density (about 240 PPI) and fast refresh rate (up to 60 Hz), making text and graphics crisp even with a small form factor. SPI communication at 4 MHz or higher ensures the display updates quickly, so keypad responses feel instant. You can also use the display’s backlight pin (PWM-capable) to control brightness, saving power in battery-powered projects. For a concrete example, a weather station with a 4x4 keypad: the display shows current conditions, and pressing keys toggles between temperature, humidity, and forecast. The keypad’s matrix scanning adds minimal latency (around 10 ms per scan), so the UI stays responsive. If you’re using an ESP32, you can leverage its dual-core processor to handle the display and keypad on separate cores, preventing SPI conflicts. The display’s SPI bus can be shared with other devices if you use separate chip select lines, but for simplicity, keep it dedicated. Memory-wise, the ST7789 driver requires about 40 KB of RAM for a full frame buffer at 16-bit color, which fits on most microcontrollers with external SRAM or on ESP32 with its 520 KB. For the keypad, use a 10kΩ pull-up resistor on each row pin to avoid floating inputs, and add a 100 nF capacitor between each column pin and ground for hardware debouncing. The matrix keypad typically has a 100 ms debounce time in software, but you can reduce it to 50 ms for faster response. The display’s refresh rate can be adjusted via SPI clock speed; at 8 MHz, a full screen update takes about 50 ms, so you can animate transitions smoothly. For a menu system, store display data in PROGMEM to save RAM, and use the keypad to navigate options like “Set Temp” or “View Logs.” The 1.14 inch 240x135 ips display has a wide viewing angle (over 160 degrees) and a contrast ratio of 1000:1, so it’s readable even in bright light. The keypad, usually with a polyester overlay, has a rated life of 1 million presses, making it durable for repeated use. In terms of power, the display draws about 20 mA with backlight on, and the keypad draws negligible current (microamps), so a 500 mAh battery can run them for 25 hours continuously. To optimize, turn off the display backlight when idle (using a transistor to switch the BL pin) and wake it with a keypad interrupt. For the keypad, use a change detection interrupt on the first row pin to wake the microcontroller from sleep, reducing power draw to under 10 µA. This is critical for battery-powered devices like a portable thermostat. The display’s SPI interface can handle up to 10 MHz, but at 4 MHz, it’s stable with long wires (up to 30 cm) if you use twisted-pair cables. For the keypad, use a ribbon cable with a ground plane to reduce crosstalk. A common mistake is using the same SPI pins for the display and an SD card; if you need both, use separate CS lines and ensure the display’s CS is high when the SD card is accessed. The keypad library can be modified to return ASCII codes for easier string handling on the display. For example, pressing ‘1’ on the keypad can send the byte 0x31 to the display, which then renders it as a character. The display’s font size can be scaled from 1 to 8 pixels using the Adafruit GFX library, but for a 240x135 resolution, a 16x16 pixel font gives 15 characters per line and 8 lines, which is readable. The keypad can also be used for password entry; the display shows asterisks for each press, and after 4 digits, it compares to a stored hash. This uses about 200 bytes of RAM for the hash. For a multi-page menu, use a state machine: each key press changes the state, and the display redraws the relevant page. The display’s write speed is about 1.5 MB/s at 8 MHz SPI, so a page with 100 characters takes under 1 ms to update. The keypad’s scan rate is 100 Hz, so you can detect double-presses by checking the state within 50 ms. The 1.14 inch 240x135 ips display has a pixel format of RGB565, which gives 65,536 colors, but for a monochrome keypad interface, you only need 2 colors, so you can use a 1-bit frame buffer to save memory. However, the ST7789 driver doesn’t support 1-bit mode natively, so you’d need to convert to RGB565 in software, which adds overhead. A better approach is to use a 4-bit color mode (16 colors) for the UI, reducing memory to 10 KB. For the keypad, use a 4x4 matrix with 16 keys, but you can also use a 4x3 matrix for 12 keys, which is common in phone-style interfaces. The keypad’s output is typically active-low, so you need to invert the logic in software. The display’s SPI bus can be clocked at 4 MHz for reliability, but if you use a level shifter, it may introduce a 10 ns delay, which is fine for 4 MHz. For a more robust design, use the display’s VSYNC pin (if available) to synchronize updates with the keypad scans, preventing tearing. The 1.14 inch 240x135 ips display is often sold with a pre-soldered header, but you can also use a FPC connector for a thinner profile. The keypad usually has a 2.54 mm pitch connector, so use a female header for easy prototyping. In terms of code structure, initialize the display in setup() with a fillScreen() call, then set the keypad’s debounce time to 50 ms. In the loop(), call keypad.getKey() and if it returns a non-zero value, update a variable and call display.print() or display.drawChar(). For a more complex UI, use a buffer for the display to avoid flickering: write all changes to a buffer, then call display.display() to update the screen. The buffer size is 240*135*2 = 64,800 bytes, which fits on an ESP32 but not on an Arduino Uno (2 KB RAM). On an Uno, you must write directly to the display, which can cause flicker if you update the same area repeatedly. To avoid this, use a double-buffer approach with an external SRAM chip (like 23K256) connected via SPI, but that adds complexity. A simpler alternative for the Uno is to use a 1-bit buffer for the UI and only update changed pixels. The keypad’s matrix can be scanned using a timer interrupt to avoid blocking the main loop. For example, set a timer to fire every 10 ms, scan the keypad, and store the last key in a global variable. This way, the display update runs in the main loop without delay. The display’s SPI communication can be interrupted by the timer, but the ST7789 driver handles this gracefully if you disable interrupts during SPI transactions. The 1.14 inch 240x135 ips display has a built-in controller that supports partial update mode, which is useful for a keypad-based UI: you can update only the area around the pressed key, reducing SPI traffic. For instance, if the keypad press changes a number on the display, you only need to redraw a 20x20 pixel area, which takes 0.1 ms at 8 MHz SPI. The keypad’s press detection can be done with a simple state machine: track the previous key state, and if it changes from HIGH to LOW, register a press. This is called edge detection. The display’s backlight can be PWM-controlled with a frequency of 1 kHz to avoid flicker, using a MOSFET like 2N7000 to switch the 3.3V line. The keypad’s rows and columns can be connected to the microcontroller’s ADC pins if you’re short on digital pins, but that requires analog scanning and is slower. For a 4x4 keypad, you need 8 digital pins, which is fine on most microcontrollers. The display’s SPI pins are typically fixed on the microcontroller (e.g., Arduino Uno: 11 for MOSI, 13 for SCK), but you can use software SPI on any pins if needed, though it’s slower. Software SPI at 1 MHz works for the display, but the keypad scan will be slower due to bit-banging. If you’re using an ESP32, you can use the hardware SPI bus (VSPI or HSPI) for the display and a separate GPIO for the keypad, which is efficient. The display’s resolution of 240x135 means you can show 15 columns of 16-pixel characters and 8 rows of 16-pixel characters, giving a 15x8 character grid. The keypad’s 16 keys can be mapped to functions like “Up”, “Down”, “Left”, “Right”, “Enter”, “Back”, and digits 0-9. For a menu system, use the keypad to scroll through a list of options on the display, with the current selection highlighted. The display’s color depth allows you to use different colors for different states: green for active, red for error, blue for idle. The keypad’s matrix can be scanned using a 4-bit multiplexer to reduce pin count, but that’s overkill for most projects. A common pitfall is the display’s initialization sequence: some ST7789 modules require a specific command sequence (like SWRESET, SLPOUT, COLMOD, DISPON) to turn on. If the display stays blank, check the wiring and the initialization code. The keypad’s library often has a default keymap; you need to set it to match your keypad’s layout. For example, a 4x4 keypad with digits 0-9 and A-D has a specific matrix wiring; if you use a different layout, change the keymap array. The display’s SPI speed can be set in the library; for a 1.14 inch display, 4 MHz is safe, but you can push to 8 MHz if the wires are short. The keypad’s debounce time is critical: too short and you get false presses, too long and you miss rapid inputs. A value of 50 ms is a good compromise. The 1.14 inch 240x135 ips display is available from various manufacturers, but the most common is the one with a 0.96-inch form factor (though it’s actually 1.14 inches diagonally). The display’s viewing angle is 160 degrees, so it’s readable from any direction, which is useful for a keypad-based interface that might be mounted on a wall. The keypad’s adhesive backing allows it to be mounted on a panel, and the display can be attached with a bezel. For a finished product, use a PCB with a 2.54 mm header for the display and a 2.54 mm header for the keypad. The display’s power consumption is 20 mA at 3.3V, so a 3.3V regulator (like AMS1117) is needed if using a 5V microcontroller. The keypad doesn’t need a regulator. The SPI bus can be shared with other devices, but the display’s CS pin must be toggled correctly. For a 1.14 inch display with a keypad, the typical use case is a smart home panel: the display shows room temperature, humidity, and time, and the keypad allows setting alarms or toggling lights. The display’s refresh rate of 60 Hz means you can show smooth animations, like a clock’s second hand moving. The keypad’s 1 million press life means it will last for years in a home environment. In terms of software, use the Adafruit ST7789 library for the display and the Keypad library for the matrix. The display’s coordinate system is (0,0) at the top-left, with x increasing to the right (240 pixels) and y increasing downward (135 pixels). The keypad’s keys are mapped to characters, and you can use a switch-case to handle each key. For a password entry, store the entered digits in an array, and when the length matches, compare to a stored string. The display’s text rendering can be done with the Adafruit GFX library’s setTextSize() and setTextColor() functions. The keypad’s scan function returns a char; if no key is pressed, it returns NULL. The 1.14 inch 240x135 ips display is small enough to fit in a handheld device, like a remote control, where the keypad is the primary input. The display’s SPI interface can be used with a 5V microcontroller if you use a level shifter, but some modules are 5V tolerant on the logic pins. Check the datasheet: the ST7789 VDD is 2.5V to 3.3V, but the logic pins can handle 5V if the module has a voltage regulator. The keypad’s matrix is passive, so it works with any voltage. For a battery-powered device, use the display’s sleep mode (via the SLPOUT command) and wake it with a keypad interrupt. The keypad’s rows can be connected to the microcontroller’s interrupt pins, so when a key is pressed, the microcontroller wakes from deep sleep. The display’s sleep current is under 1 µA, and the keypad’s leakage is negligible. This setup can achieve a battery life of months. The 1.14 inch 240x135 ips display is also available with a capacitive touch overlay, but that’s a different product; for a keypad, you want the resistive or membrane type. The keypad’s matrix can be scanned using a 4-bit shift register to reduce pin count, but that adds complexity. For a simple project, just use the 8 pins. The display’s pixel density is 240 PPI, which is higher than many larger displays, so text is sharp. The keypad’s tactile feedback is provided by the dome switch under each key, which has a 100g actuation force. This is good for a desktop device but might be too stiff for a handheld. The display’s brightness is 400 cd/m², which is readable in direct sunlight if you use a polarizer. The keypad’s polyester overlay is UV-resistant, so it won’t yellow over time. For a 1.14 inch display with a keypad, the typical project is a “smart badge” that shows a name and allows changing it via the keypad. The display’s 240x135 resolution can show a 30x30 pixel icon, which is good for a logo. The keypad’s 16 keys can be used for a 4x4 grid of icons on the display, each key corresponding to a function. The SPI bus can be daisy-chained to other devices, but for the display, keep it simple. The 1.14 inch 240x135 ips display is a popular choice for this because it’s cheap (around $5) and widely available. The keypad is also cheap (around $2). Together, they form a complete user interface for under $10. For a more advanced project, use an ESP32 with Wi-Fi to send keypad presses to a server and display the response on the screen. The display’s SPI speed can be set to 20 MHz on an ESP32, but the ST7789’s maximum is 62.5 MHz, so you’re limited by the microcontroller. The keypad’s scan time is 10 ms, so the total loop time is under 20 ms, allowing for a 50 Hz update rate. The display’s frame buffer can be used to store a background image, and the keypad updates only the foreground. For example, a weather app: the background shows a sky gradient, and the keypad toggles between temperature and humidity text. The 1.14 inch 240x135 ips display has a 4:3 aspect ratio, which is good for text. The keypad’s matrix can be scanned using a 4-bit ADC if you use a resistor ladder, but that’s less common. For a reliable design, use the digital pins. The display’s backlight can be controlled with a PWM pin on the microcontroller, using a frequency of 1 kHz to avoid audible noise. The keypad’s debounce can be done with a 100 nF capacitor on each column pin, but software debounce is simpler. The 1.14 inch 240x135 ips display is often used with a 1.14 inch 240x135 ips display, and the keypad is a standard 4x4 matrix. The combination is perfect for a portable terminal. For a step-by-step guide, first connect the display’s VCC to 3.3V, GND to ground, CS to pin 10, DC to pin 9, MOSI to pin 11, SCK to pin 13, and BL to pin 8 (with a
Order This Week's Harvest

From our field to your kitchen — within 36 hours.

Heritage breeds, single-origin cuts and the season's best produce, harvested Tuesday and on London benches by Wednesday lunch.

Order This Week