/*
CS - 15
RST - 4
DC - 2
MOSI - 23
SCK - 18
MISO - 19
SCL - 22
SDA - 21
*/
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Adafruit_FT6206.h>
#include <Wire.h>
Adafruit_FT6206 ctp = Adafruit_FT6206();
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define BLACK 0X0000
#define BLUE 0X001F
#define RED 0XF800
#define GREEN 0X07E0
#define CYAN 0X07FF
#define MAGENTA 0XF81F
#define YELLOW 0XFFE0
#define WHITE 0XFFFF
void setup()
{
Serial.begin(115200);
tft.begin();
tft.setRotation(3);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(1);
tft.setCursor(100, 15);
tft.print("Touch Any point in Screen");
if(!ctp.begin(40))
{
while(1);
}
}
void loop()
{
int x;
int y;
if(!ctp.touched())
{
delay(10);
return;
}
TS_Point p = ctp.getPoint();
x = 320 - p.y; //Value start from High(320) to Low(0). Subtract High from touch point
y = p.x; //x and y are switched. so x = p.y and y = p.x
Serial.print(x);
Serial.print(", ");
Serial.print(y);
Serial.println("");
delay(100);
}
Loading
ili9341-cap-touch
ili9341-cap-touch