#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
const int cs = 10;
const int dc = 9;
const int resetPin = 2;
const int buttonPin = 3;
bool buttonState = false;
int count = 0;
Adafruit_ILI9341 tft = Adafruit_ILI9341(cs,dc);
void setup() {
pinMode(buttonPin, INPUT);
pinMode(resetPin, INPUT);
SPI.begin();
tft.begin();
tft.setCursor(5,110);
tft.setTextSize(4);
tft.setTextColor(ILI9341_GREEN);
}
void loop() {
int buttonClicked = digitalRead(buttonPin);
int resetClicked = digitalRead(resetPin);
if (buttonClicked == LOW && !buttonState) {
buttonClicked = true;
count++;
tft.fillScreen(ILI9341_BLACK);
}
if (buttonClicked == HIGH && buttonState) {
buttonClicked = false;
delay(100);
}
if (resetClicked == LOW) {
count = 0;
tft.fillScreen(ILI9341_BLACK);
}
tft.setCursor(50,150);
tft.print("Count: ");
tft.setCursor(100,200);
tft.print(count);
}