SPI TFT display/What the pixels cost/12. The backlight runs both ways
What the pixels cost · 12 of 20

The backlight runs both ways

One transistor switches the lamp, and a 10 kΩ resistor holds it off until BL is driven. On five boards it sits on the lamp's low side and BL high is on; on the 0.96 inch it sits on the high side and BL low is on. Bridge the jumper and the pad is no longer yours to drive.

Two circuits, one board

The picture and the light are not the same thing. The controller draws into the glass whether or not there is a lamp behind it, and the lamp shines whether or not anything has been drawn.

On these boards there is one more step between BL and the lamp: BL does not go to the controller at all. It goes to the gate of a transistor, and the transistor decides whether the lamp's current flows. A 10 kΩ resistor holds that gate at the level that keeps the transistor off, so the lamp is dark until BL is driven, and also while BL floats.

What BL does to the lamp
BSS138 · low side, active HIGH
Board
BL pad
BL jumper
backlight()200
Lamp is on when BL is
HIGH
Library writes to the pin
200
Brightness
200
On this board BL high is lamp on. The library takes backlight(0..255) as brightness and flips it for the 0.96 inch, so the sketch never needs to know. The lamp is 5 kHz PWM either way; the transistor is the only thing that is different.

Pick a board and leave BL alone: the lamp is off. Drive it from the library: the lamp follows backlight(n). That is the same on all six. What differs is which level means on, and it differs because of which transistor is fitted.

Five boards: the transistor is below the lamp

The 1.8, 2.0, 2.4, 2.8 and 3.5 inch boards have a BSS138, an N-channel transistor, between the lamp and ground. The lamp's other end is on 3V3 and a 2.2 Ω resistor is in its current path. BL is the gate, and the 10 kΩ goes from the gate to GND. BL high turns the transistor on and lights the lamp. BL low, or nothing, leaves it off.

The 0.96 inch: the transistor is above the lamp

The 0.96 inch has an AO3401, a P-channel transistor, between 3V3 and the lamp. The 10 kΩ goes from the gate to 3V3, which holds it off. BL has to go low to turn it on. So on this one board, 255 on the pin is dark and 0 is bright, and nothing about that looks like a fault: the screen still dims and still brightens, only the wrong way round.

The library already knows

backlight(0) to backlight(255) is brightness on every board, in both languages. The polarity is a column in the panel table, so the constant that selects the board selects the polarity with it, and there is nothing to remember. The library drives BL with 5 kHz PWM on every board, so full brightness is 255 rather than a different call.

The figure is for the cases where you meet the polarity anyway: reading somebody else's driver, or writing your own. If you ever need to override it:

display.setBacklightActiveLow(false);   // any time, before or after begin()

printInfo() reports the polarity and marks it (forced) when you have overridden the table, which is how you tell a deliberate override from a misconfiguration three weeks later.

The jumper, and the pad you must then leave alone

The BL solder jumper ties the pad to the level that lights the lamp: 3V3 on the five boards, GND on the 0.96 inch. It ships open. Bridged, the lamp is on at full and BL is a fixed level.

That is a fine way to save a pin. It is also the one place the board can be hurt from the sketch: the library drives BL, and a driven pin against a strapped rail is a short through the pin. Step the figure to bridged and drive it from the library below full brightness to see it. The cure is one line, pins.backlight = -1, set through setWiring() before begin().

What the lamp costs

It is usually the largest single load on a board like this and it switches on all at once. On a host whose 3.3 V regulator is already close to its limit, that step can drop the rail far enough to reset the microcontroller, which looks like a crash in the sketch and is not one.

begin() switches the lamp on at full, so the step happens there and cannot be softened from the sketch. A supply with headroom is the cure.

When it does not work

My 0.96 inch is brightest at zero and dark at 255

That board's backlight is active low: pulling BL down turns the lamp on, because its transistor is a P-channel part on the lamp's high side. You have found the polarity the hard way. With the library, backlight(0..255) is brightness on every board; this only happens when you write the pin directly.

The screen is black but I can see the picture at an angle

The controller is being drawn on correctly and the lamp is off. Check BL: unconnected, or tied the wrong way for that board, or set to zero somewhere in the sketch. The board holds the lamp off until BL is driven, so a BL wire you forgot looks exactly like this. Nothing is wrong with the other seven holes.

The backlight is on but there is no picture

The opposite fault, and a more useful one: the lamp proves the board has 3V3 and ground and that BL is right. What is left is DC, RST, CS, the clock and data, or a sketch that has not drawn anything yet. Start with DC and RST.

I bridged the BL jumper and now dimming does nothing, or the pin runs hot

The jumper ties the pad to the rail that lights the lamp, so the lamp is on at full and cannot dim, and any PWM written to the pad fights the rail. Take the BL wire off, and set pins.backlight to -1 in the library's wiring before begin() so backlight() stops writing to it.

The host resets when the backlight comes on

The lamp switches on all at once and is usually the largest load on the board, though this book has no measured current for it. If your supply is marginal the whole host can dip and reset. begin() switches the lamp on at full, so the step happens there; a rail with more headroom is the cure, and a dip only at begin() is this.

Where this goes next

A dark screen first, then a white one, and how to tell them apart without a meter.

When nothing appears →

Edit this page — content/books/lcd/the-backlight-runs-both-ways.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

This page covers several products. Choose yours to see the right discussions.

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →