#include <Adafruit_GFX.h>       // include Adafruit graphics library
#include <Adafruit_ILI9341.h>   // include Adafruit ILI9341 TFT library
#define a 3
#define b 4
#define TFT_CS    8      // TFT CS  pin is connected to arduino pin 8
#define TFT_RST   9      // TFT RST pin is connected to arduino pin 9
#define TFT_DC    10     // TFT DC  pin is connected to arduino pin 10
int A=0, B=0;
int cnt=1;
// initialize ILI9341 TFT library
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

void setup() {
tft.begin(); // инициализируем дисплей
pinMode(a, INPUT);
}
void loop(){
A=digitalRead(a);
B=digitalRead(b);

if(A>0 && B<1)
{cnt=cnt-1;A=0;}

tft.fillRect(120, 0, 110, 30, ILI9341_BLACK);
tft.fillRect(121, 51, 111, 31, ILI9341_BLACK);
tft.fillRect(121, 101, 111, 31, ILI9341_BLACK);


tft.fillRect(120, 0, 110, 30, ILI9341_GREEN);
tft.drawRect(121, 51, 111, 31, ILI9341_GREEN);
tft.drawRect(121, 101, 111, 31, ILI9341_GREEN);

if(A<0 && B<1)
tft.drawRect(120, 0, 110, 30, ILI9341_GREEN);
tft.fillRect(121, 51, 111, 31, ILI9341_GREEN);
tft.drawRect(121, 101, 111, 31, ILI9341_GREEN);

if(A<0 && B<1)
tft.drawRect(120, 0, 110, 30, ILI9341_GREEN);
tft.drawRect(121, 51, 111, 31, ILI9341_GREEN);
tft.fillRect(121, 101, 111, 31, ILI9341_GREEN);

tft.setCursor(140, 2);
tft.setTextColor(ILI9341_BLACK);  
tft.setTextSize(3);
tft.println("Gas");

tft.setCursor(135, 54);
tft.setTextColor(ILI9341_BLACK);  
tft.setTextSize(3);
tft.println("Water");

tft.setCursor(135, 106);
tft.setTextColor(ILI9341_BLACK);  
tft.setTextSize(3);
tft.println("Temp");

tft.setCursor(40, 200);
tft.setTextColor(ILI9341_WHITE);  
tft.setTextSize(4);
tft.println("Sensors");
delay(5000);
}