#include <Arduino.h>
#include <Adafruit_ILI9341.h>
#include <Button2.h>
#define TFT_CS 15
#define TFT_DC 33
#define TFT_RST -1
#define BUTTON_PIN 14
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
Button2 myBtn = Button2(BUTTON_PIN);
bool displayOn = true;
void buttonPressed(Button2& btn) {
if (displayOn) {
tft.fillScreen(ILI9341_BLACK);
displayOn = false;
} else {
tft.fillScreen(ILI9341_RED);
displayOn = true;
}
}
void setup() {
tft.begin();
tft.setRotation(3);
myBtn.setClickHandler(buttonPressed);
}
void loop() {
myBtn.loop();
}