How to change the brightness of a 1.77 inch TFT display
To change the brightness of a 1.77 inch TFT display, you typically control the backlight LED current or pulse-width modulation (PWM) signal. Most of these small displays, like the 1.77 inch 128x160 tft display using the ST7735S driver, rely on a dedicated backlight pin (often labeled BL, LEDA, or backlight). The simplest method is to adjust the voltage or current on that pin. For example, connecting the backlight pin directly to 3.3V gives full brightness, while using a series resistor (e.g., 100 ohms) reduces current and lowers brightness. However, the most flexible and common approach is to feed a PWM signal from a microcontroller (like an Arduino, ESP32, or STM32) into the backlight pin. By varying the duty cycle from 0% to 100%, you can achieve smooth dimming from off to maximum. The ST7735S datasheet specifies a typical forward voltage of 3.0V to 3.3V for the backlight LEDs, with a maximum current around 20mA to 40mA, depending on the specific module. Overdriving beyond that can damage the LEDs or reduce lifespan, so always check your module’s specifications. If your display module has a separate backlight driver IC (like the XC6210 or similar), you might need to adjust an external resistor or use a PWM pin that connects to the enable or dimming input. For the 1.77 inch 128x160 tft display from DisplayModule, the backlight is controlled via a dedicated pin that can handle PWM directly from a 3.3V logic level. Many hobbyists use the analogWrite() function in Arduino with a frequency of around 500Hz to 1kHz, as higher frequencies reduce flicker but may cause audible noise if the driver is not designed for it. The human eye perceives brightness logarithmically, so a linear PWM duty cycle change (e.g., from 50% to 100%) appears as a smaller change at high brightness. For better perceived linearity, you can use a gamma correction table or a logarithmic mapping function in your code. For example, mapping duty cycle values from 0 to 255 using a power function like output = pow(input / 255.0, 2.2) * 255 gives a more natural dimming experience. This is especially important if you are building a user interface where brightness adjustments are frequent. The actual brightness in nits (candelas per square meter) for a 1.77 inch TFT varies by manufacturer, but typical values range from 200 to 350 nits at full current. At 50% PWM duty cycle, the perceived brightness is roughly 70% to 80% of maximum due to the logarithmic response. You can measure the actual brightness with a lux meter or a smartphone app to calibrate your PWM values. If you are using a battery-powered device, lowering brightness also reduces power consumption. The backlight LED typically draws 15mA to 30mA at full brightness, so reducing to 50% duty cycle can cut current draw to around 8mA to 15mA, depending on the driver efficiency. Some advanced modules include a digital potentiometer or I2C-controlled backlight driver, but most 1.77 inch displays use simple analog control. Another method is to use a transistor or MOSFET to switch the backlight, especially if your microcontroller pin cannot source enough current. For example, an N-channel MOSFET like the 2N7002 can handle up to 200mA, which is more than enough. The gate is driven by the PWM pin, the drain connects to the backlight cathode (or anode depending on configuration), and the source goes to ground. This isolates the backlight current from the microcontroller pin. If you are using an Arduino Uno, the PWM pins (3, 5, 6, 9, 10, 11) operate at 490Hz or 980Hz, which is fine for backlight dimming. On an ESP32, you can use the LEDC library to set any frequency from 1Hz to 40MHz, but 1kHz is a good default. For the STM32, you can use timer PWM outputs with a 16-bit resolution for finer control. The table below summarizes common PWM settings for different microcontrollers when controlling a 1.77 inch TFT backlight:
| Microcontroller | PWM Frequency | Resolution | Recommended Pin | Library |
|---|---|---|---|---|
| Arduino Uno | 490 Hz or 980 Hz | 8-bit (0-255) | 3, 5, 6, 9, 10, 11 | analogWrite() |
| ESP32 | 1 kHz to 5 kHz | 8-bit to 16-bit | Any GPIO | LEDC |
| STM32 (Blue Pill) | 1 kHz | 16-bit (0-65535) | PA0, PA1, etc. | HAL or Arduino core |
| Raspberry Pi Pico | 1 kHz | 16-bit (0-65535) | GP0-GP28 | PWM class |
The backlight pin on most 1.77 inch TFT modules is active high, meaning applying a high voltage (3.3V) turns it on, and a low voltage (0V) turns it off. Some modules have an inverted backlight, so check the datasheet or use a multimeter to measure the pin voltage when the display is on. If the backlight stays on even when the pin is low, you may need to use a P-channel MOSFET or a logic-level inverter. For example, a simple 2N3904 NPN transistor with a 1k ohm base resistor can invert the PWM signal. The collector connects to the backlight pin, the emitter to ground, and the base to the PWM pin. When the PWM is high, the transistor conducts, pulling the backlight pin low, turning it off. When the PWM is low, the transistor is off, and the backlight pin is pulled high by an external resistor (e.g., 10k ohm to 3.3V). This inversion is common in some modules where the backlight is common anode. Always verify the polarity of your specific display. The ST7735S driver itself does not control brightness; it only handles the display data. The backlight is a separate circuit. Some pre-built modules like the one from Adafruit or DisplayModule have a built-in resistor or transistor for basic control, but you still need to provide the PWM signal. If you are using a library like Adafruit_ST7735, there is no built-in brightness function, so you must handle it externally. You can write a simple function like setBacklight(uint8_t brightness) that maps the value to a PWM duty cycle. For example, on Arduino:
void setBacklight(uint8_t brightness) {
analogWrite(backlightPin, brightness);
}
This assumes the backlight pin is connected to a PWM-capable pin. If you want to avoid flicker, set the PWM frequency to at least 1 kHz. Some people report visible flicker at 490 Hz, especially when the display is viewed peripherally or in motion. Increasing the frequency to 1 kHz or higher eliminates this. However, very high frequencies (above 10 kHz) can cause the backlight driver to become less efficient or generate audible whine from the inductor in the boost converter if the module uses one. Most 1.77 inch TFT modules use a simple resistor-limited backlight, not a boost converter, so high frequencies are fine. The backlight LED forward voltage is typically around 3.0V to 3.2V, and the current is limited by a series resistor (often 10 to 47 ohms) on the module. If you want to measure the actual current, use a multimeter in series with the backlight pin. At full brightness, you should see 15mA to 30mA. If you see more than 40mA, the resistor may be too small, and you risk overheating the LED. You can add an external resistor in series to reduce brightness and protect the LED. For example, adding a 100 ohm resistor in series with a 3.3V supply and a 20mA LED will drop the current to about 10mA, reducing brightness by roughly 50%. This is a simple hardware-only method if you don't want to use PWM. Another hardware method is to use a variable resistor (potentiometer) in series with the backlight. A 500 ohm trimmer pot allows you to adjust brightness manually. This is useful for fixed installations where you set the brightness once. But for dynamic adjustment (e.g., based on ambient light sensor), PWM is better. You can also use a digital potentiometer like the MCP41010 controlled via SPI, but that adds complexity and cost. The most common and cost-effective method remains PWM from a microcontroller. If you are using a display with an integrated touch controller or a breakout board, the backlight pin is usually clearly labeled. On the 1.77 inch 128x160 tft display from DisplayModule, the pinout includes a backlight pin labeled "BL" that accepts 3.3V logic. The module has a built-in 10 ohm resistor, so the maximum current is around 30mA at 3.3V. You can connect this pin directly to a PWM output from an ESP32 or Arduino. The module also has a jumper to enable or disable the backlight, but for dimming, you use the PWM. The datasheet for the ST7735S does not specify backlight characteristics, but the module manufacturer typically provides a schematic. For example, the DisplayModule version uses a common anode configuration where the backlight anode is connected to VCC (3.3V) and the cathode is pulled low through a transistor. So applying a PWM signal to the base of that transistor controls brightness. In this case, the PWM signal is active low—meaning a low duty cycle gives high brightness. You need to invert the PWM in software. For example, on Arduino, you can write analogWrite(backlightPin, 255 - brightness). This is a common gotcha. Always test with a multimeter to see the voltage on the backlight pin relative to ground. If the pin is at 3.3V when the display is on, then it's active high. If it's at 0V, then it's active low. The table below shows common pin configurations for 1.77 inch TFT modules:
| Module Brand | Backlight Pin Label | Active Level | Max Current (mA) | Recommended PWM Frequency |
|---|---|---|---|---|
| DisplayModule | BL | Active Low (PWM inverted) | 30 | 1 kHz |
| Adafruit 1.8" TFT | LED | Active High | 20 | 500 Hz |
| Generic ST7735S | LEDA or BL | Active High (often) | 25-40 | 1 kHz |
| Waveshare 1.77" | BL | Active High | 20 | 1 kHz |
If you are using a battery-powered project, you can also use a dedicated backlight driver IC like the TPS61165 or the MP3302, which have a dimming pin that accepts PWM. These ICs boost the voltage to drive multiple LEDs in series, but for a single 1.77 inch display, they are overkill. The simple PWM method works fine. One thing to watch out for is the PWM frequency interfering with the display's SPI communication. If you run the PWM at a frequency that is a harmonic of the SPI clock, you might see noise on the display. This is rare but can happen if you use a very high frequency like 10 MHz. Stick to 1 kHz to 5 kHz, and you'll be fine. Another factor is the temperature. The backlight LED's brightness decreases as temperature increases, but the effect is small for typical indoor use. If you are using the display outdoors in direct sunlight, you may need to run the backlight at full brightness and use a sunlight-readable polarizer. The 1.77 inch TFT typically has a brightness of 200-300 nits, which is not enough for direct sunlight. You can increase brightness by overdriving the LED slightly, but this reduces lifespan. For example, running at 40mA instead of 20mA may double brightness but cut LED life from 50,000 hours to 10,000 hours. The datasheet for the LED backlight usually specifies a maximum continuous current. If you don't have the datasheet, assume 20mA per LED. Some modules use two LEDs in parallel, so total current can be 40mA. To measure the actual current, use a multimeter in series with the backlight pin. If you are using a PWM signal, the average current is duty cycle times the maximum current. So 50% duty cycle at 20mA gives 10mA average. This is safe for the LED. For more precise control, you can use a constant current sink like the LM334 or a simple transistor with a resistor. But again, PWM is sufficient for most users. If you are writing code for a project, consider adding a brightness control menu that stores the value in EEPROM. For example, on Arduino, you can use EEPROM.write() to save the brightness level and read it on startup. This way, the display remembers the last setting. The user can adjust brightness using a button or a potentiometer. For a potentiometer, read the analog value (0-1023) and map it to 0-255 for PWM. For buttons, increment or decrement the value with a short press, and maybe use a long press for a preset. The resolution of the human eye is about 1% for brightness changes, so 256 steps are more than enough. In practice, 10-20 steps are sufficient for most users. You can also implement an automatic brightness control using an ambient light sensor like the LDR or the BH1750. Connect the sensor to the microcontroller, read the light level, and map it to PWM duty cycle. For example, in bright light, set PWM to 100%; in dim light, set to 20%. This saves power and improves readability. The response time of the backlight is instant, so you can update the PWM value every few seconds. The BH1750 has a resolution of 1 lux and an I2C interface, making it easy to integrate. The code would look like:
uint16_t lux = readBH1750();
uint8_t brightness = map(lux, 0, 1000, 50, 255); // clamp to 50-255
setBacklight(brightness);
This gives a minimum brightness of 20% (50/255) to avoid the display being too dim. You can adjust the mapping based on your environment. Another factor is the viewing angle. The 1.77 inch TFT has a typical viewing angle of 120 degrees, but brightness falls off at extreme angles. This is a property of the LCD panel, not the backlight. So adjusting brightness does not affect viewing angle. If you need a wider viewing angle, you need a different display technology like IPS. The ST7735S driver supports 262K colors, but the backlight brightness does not affect color accuracy. However, at very low brightness, the color gamut may appear slightly reduced due to the eye's scotopic vision. This is a biological effect, not a display issue. For professional use, keep brightness above 50%. If you are using the display in a medical device or a critical application, you should calibrate the brightness with a photometer. The typical brightness measurement for a 1.77 inch TFT is done with a luminance meter at the center of the screen. The uniformity across the screen is usually within 20% for cheap modules, meaning the edges may be dimmer. This is due to the edge-lit LED design. The backlight LED is usually placed at the edge of the light guide, so the center is brightest. If you need uniform brightness, you can use a diffuser film, but that reduces overall brightness. For most hobby projects, this is acceptable. The power consumption of the backlight is a significant portion of the total display power. The ST7735S itself draws about 1-2mA, while the backlight draws 20-30mA. So dimming the backlight to 50% reduces total power from about 30mA to 15mA, which is a 50% savings. This is critical for battery-powered devices. For example, a 2000mAh battery would last 66 hours at full brightness but 133 hours at 50% brightness. This is a huge difference. In sleep mode, you can turn off the backlight completely by setting PWM to 0 or using a MOSFET to cut power. The display driver can also be put to sleep via SPI command, but the backlight is separate. So for maximum battery life, turn off the backlight when not in use. Some modules have a "display off" command that turns off the display but leaves the backlight on. You need to handle both. In summary, the most practical way to change brightness is PWM control on the backlight pin, with a frequency of 1 kHz, using a microcontroller. Always check the active level of your module and invert the PWM if needed. Use a multimeter to measure current and avoid exceeding 40mA. For advanced users, add an ambient light sensor or a potentiometer for manual control. The key is to understand your specific module's pinout and electrical characteristics. The 1.77 inch 128x160 tft display from DisplayModule is