Turn off the TFT backlight Adafruit 1.3"

So I'm trying to build a thing where when I press a button it displays an image for 20 seconds. I want long battery life so after 20 seconds I want to turn off the screen to save battery life.

I have been able to accomplish the screen going on, hitting a button to display an image and switch when I hit a different button. What I have no idea is how to turn the screen off. I've been able to figure out from forums there is turning the TFT off and turning the backlight off. I think I want the backlight to go off as that is what saves the most battery life.

I have the screen pin Lite plugged into D6. I assume I have to set that to something?


if (buttonStateBlue == HIGH) {
  //Code to turn screen on
  reader.drawBMP("/redSquare.bmp", tft, 0, 0); //display an image on screen
  Serial.print("blue button on"); // serial log to confirm it worked
  delay(20000); //wait 20 seconds
  //Code to turn screen off

If you haven't figured this out yet, you are correct:

gamefe: I have the screen pin Lite plugged into D6. I assume I have to set that to something?

You simply have to turn pin D6 off and on as you want. Something simple like this should do the trick:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(D6, OUTPUT);

// the loop function runs over and over again forever
void loop() {
  digitalWrite(D6, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(D6, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second

That code is nothing more than the arduino Blink example that turns off and on the built in LED, adapted to work on pin D6 instead.

For reference: https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/ https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/

Optionally, you could also connect the display's lite pin to an analog pin and change the analog pin's value over time to fade in/out the brightness of the back light.

Hope this helps, Randy