I have bought a 2.5" TFT shield online, which is equipped with the ILI9341 controller. I need to dim the intensity of the background LEDs to match ambient light.

This particular shield does not provide a pin to control the intensity of the LEDs with PWM via a separate input, so I need to dim the background LEDs of this display via software.

The zip file with the libraries can be downloaded here.

Does one of you know how can issue a command to the TFT display to dim the background LEDs?

Thanks in advance!


I wrote a new function to set the display's brightness by controlling the background LEDs, but something is missing as I can seem to be writing correctly to the display. So I'm trying to get the display to answer to a known command first, like 0x28 (Display Off).

The new function is defined in Adafruit_TFTLCD.cpp:

// Set display brightness (background LED's)
void Adafruit_TFTLCD::setDisplayBrightness(uint8_t x) {
  // Try with 0x28 (Display Off) to see if display reacts
  writeRegister8(0x28, 0);

The function prototype is defined in Adafruit_TFTLCD.h

// New functions
void setDisplayBrightness(uint8_t x);

Then I call the function in my main loop. To make sure, I first write some rectangles on screen, wait 5 seconds, then fill the screen with blue, call the new function and enter an endless loop so no other commands can interfere:

  tft.setDisplayBrightness(10); // Which really is command 0x28 to test

Any clues what I might be missing?



I got so far as to have the ILI9341 react to some commands, but not all the time, and not to all commands. I suspect there is something in the way you issue the commands that I'm missing( timing?, sequence?, other?)

Here is what I have found out so far:

I can get the display to react to the Display Off command (0x28), but only when I issue it in the begin(..) function. So, the original code in Adafruit_TFTLCD.cpp is like this:

void Adafruit_TFTLCD::begin(uint16_t id) {
writeRegister8(ILI9341_DISPLAYON, 0); 

If I change it to the following the display reacts by remaining white:

void Adafruit_TFTLCD::begin(uint16_t id) {
writeRegister8(ILI9341_DISPLAYON, 0); 
writeRegister8(ILI9341_DISPLAYOFF, 0); // Display off is declared as 0x28

So, I have a reaction to command 28h.

Then I tried function 0x51 like this in the begin(...) function:

void Adafruit_TFTLCD::begin(uint16_t id) {
writeRegister8(ILI9341_DISPLAYON, 0); 
writeRegister8(0x51, 0x80); // Test command 0x51 - background intensity

To no effect :-(

I even added command 0xBE (background PWM frequency) to see if it had any effect, but nothing :-(

void Adafruit_TFTLCD::begin(uint16_t id) {
  writeRegister8(ILI9341_DISPLAYON, 0);
  writeRegister8(0xbe, 0x80);
  writeRegister8(0x51, 0x0);

Also if I issue the 0x28 command:

writeRegister8(ILI9341_DISPLAYOFF, 0)

elsewhere in Adafruit_TFTLCD (e.g. in FillScreen, Fill Rect etc, it doesn't work either).

Any ideas? They would be highly appreciated!

  • 2
    What shield? We need to know that to know if it is even possible. The ILI9341 doesn't provide back-light control like chips such as the SSD1963 does, so you can't do it with the driver. If it is hard wired to +5V you are out of luck.
    – Majenko
    Jan 21, 2016 at 14:35
  • Other than command 0x51? Jan 21, 2016 at 14:39
  • Ok, that's a new one on me. I was going on my experience of other ILI chips and this is the first I have seen with an LED driver in it. TBH I haven't used a 9341 display, only a 9340. It's a display I have been meaning to get hold of to implement in DisplayCore but just not got round to it. Ok, so ignore that comment about no control - there may be control if it is used, and the library may be able to do it or be changed to do it. However, we still need to know what shield it is so we know how it's wired up.
    – Majenko
    Jan 21, 2016 at 14:54
  • That was an interesting challenge. There seems to be a set of commands for backlight control according to the product specification; brightness level, pwm frequency, brightness transition, etc. It will require writing some new driver functions. Jan 21, 2016 at 17:54
  • Gents, This is indeed an interesting challenge :-). I bought the board here: banggood.com/… And I asked for the schematic which is here: copy.com/s/… There are detailed photos on their site and you can see how the shield looks. Unfortunately, the seller doesn't have more information.
    – kxtronic
    Jan 21, 2016 at 19:54

5 Answers 5


I got in contact with the manufacturer of the shield, they informed that the background LEDs are hardwired and not controllable via the ILI9341. So, it is not possible to dim the background light in this shield


I will look for another TFT shield and make sure it's dimmable before buying.

  • That's strange. there is no BL pin? Have you got the schematics or at least a picture of the module?
    – next-hack
    Aug 26, 2017 at 8:59
  • No, there's no BL pin available on this board. I asked the manufacturer and they responded that this pin is hardwired and I don't feel like cutting/soldering PCB tracks.
    – kxtronic
    Sep 1, 2017 at 8:40
  • Too bad :/ Such a stupid decision by the manufacturer.
    – next-hack
    Sep 1, 2017 at 8:59
  • Yep. In the end I abandoned the project because of other reasons. I found out that other boards communicate serially and provide a way to dim the backlight with a command. It means researching TFT shields before buying :-)
    – kxtronic
    Sep 1, 2017 at 9:08

It looks like it should be controllable with command 0x51.

I would modify the library and add a new method to the Adafruit_ILI9341_8bit_AS class - something like:

void Adafruit_ILI9341_8bit_AS::setBacklight(uint8_t brightness) {
    writeRegister8(0x51, brightness);

Then you can change the brightness by calling that method on your TFT object in your sketch. (Don't forget to add the prototype to the class definition in the header file of course).

  • Hi Majenko, I followed your advise but I still can get this to work. Please see my update in the original question
    – kxtronic
    Jan 22, 2016 at 5:57

After looking at the schematic (mine is different) but on pin 16 is labeled as BL. If that is indeed the power for the LED backlights then a voltage applied to it should vary the brightness. Caution:You need to know how much current the LEDs are pulling. If over the limit for a PWM pin you will have to run it through a transistor to boost the current.


Most of thees cheap Chinese LCD modules have the LED backlight hardwired to Vcc and GND and cannot be controlled.

However, after inspecting the module I have and some similar ones online I found that most have the Back-light LEDs pins available through the LCD panel flex cable. If yours is similar to the one in the picture then you will notice that the main flex cable is for the LCD itself, and there are usually two other flex cables connected to it. The one on the left is for touch panel (if equipped), and the one of the right is for the back light LEDs (sometimes it is connected on the backside of the flex).

enter image description here

In this panel and on mine (a little different from this) they are labeled as K1, K2, K3 and K4 which are mostly the Cathode side of the LED (negative side) and they are exposed as separate pins in the main flex cable, while the Anode is soldered to the main flex cable Vcc plane and cannot be easily accessed without desoldering the LED flex cable.

enter image description here

So in ordered to control the backlight you have to cut the trace on the PCB (not the flex cable) and connect it to a transistor which you control through the Arduino.

  • Double check the polarity in your LCD panel, it could be different from mine.

I have successfully dimmed the backlight on a ili9341 by simply modulating the pin the LED pin is connected to.

Note, I am using a teensy 3.2 your mileage may vary.


void loop() {
analogWrite(ledPin, 60);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.