/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define TEXT_SIZE 2
int lastAnalogValue = 0;
void setup() {
// Initialize the LCD
tft.begin();
// Set the text size and background color
tft.setTextSize(TEXT_SIZE);
tft.fillScreen(ILI9341_BLACK);
}
void loop() {
// Read the analog input value
int analogValue = analogRead(A0);
// Clear the screen
// Print the analog value to the LCD
if(analogValue != lastAnalogValue){
tft.fillScreen(ILI9341_BLACK);
// Set the text color and position
tft.setCursor(200, 200);
tft.setTextColor(ILI9341_WHITE);
tft.print(analogValue);
lastAnalogValue = analogValue;
}
}