/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#define WHITE 0xFFFF
//#include "DS1307RTC"
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "XPT2046_Touchscreen.h"
#define GREEN 0x07E0
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
int temperatura=0;
int i=0;
void setup() {
tft.begin();
tft.setRotation(1);
tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
//tft.println("Hello, TFT!");
int analogico=analogRead(A0);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(1);
tft.setCursor(0, 92);
tft.println("5 C");
tft.setCursor(0, 183);
tft.println("2 C");
tft.drawLine(0, 180, 320, 180, GREEN);
tft.drawLine(0, 181, 320, 181, GREEN);
tft.drawLine(0, 100, 320, 100, GREEN);
tft.drawLine(0, 101, 320, 101, GREEN);
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
void loop()
{
int i=0;
//temperatura=240-temperatura;
for(int i=0;i<=320;i++)
{
int analogico=analogRead(A0);
int temperatura=map(analogico, 0 , 1023 , 0, 240);
tft.setTextSize(2);
tft.setCursor(250,3);
tft.println(temperatura);
tft.drawPixel(i, 240-temperatura, WHITE);
delay(1000);
}
}