// tft.setTextColor(ILI9341_RED);
// Future Scope:
// Image Processing:
// Speed Cam
// No Parking
// One-Way
// NodeMcU Pins Connection
// #define TFT_MOSI D7
// #define TFT_SCLK D5
// #define TFT_CS D2
// #define TFT_DC D4
// #define TFT_RST D3
// Library Fuctions
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// Colours
#define Black 0x000000
// Arduino Pins Connection
#define TFT_DC 9
#define TFT_CS 10
#define RESET 8
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, RESET);
// Variables
String Weather;
int Temperature;
int Display_Speed;
String Traffic_Data;
// Functions
void speed(String weather);
void traffic_warning(int data);
// Initial Setup
void setup() {
tft.begin();
Serial.begin(9600);
tft.setRotation(1);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
}
void loop() {
tft.setCursor(0,0);
tft.print("Checking"); // Initial Mesaage..
tft.setCursor(0,30);
tft.print("The Atmosphere");
delay(3000);
// Speed using random input
Temperature = random(1,50);
Serial.println(Temperature);
if( Temperature <= 35 && Temperature >= 30)
{
Weather = "Hot";
temp(Weather);
}
else if(Temperature >= 15 && Temperature <= 35)
{
Weather = "safe";
temp(Weather);
}
else if(Temperature <= 15 && Temperature >= 0){
Weather = "Cold";
temp(Weather);
}
else{
Weather = "Hot";
temp(Weather);
}
tft.fillScreen(Black);
}
void temp(String weather)
{
tft.fillScreen(Black);
if (weather.equals("Hot"))
{
tft.setCursor(0,0);
tft.print("Very Hot");
tft.setCursor(0,30);
tft.print("Move Away");
delay(3000);
tft.fillScreen(Black);
}
if (weather.equals("safe"))
{
tft.setCursor(0,0);
tft.print("Safe");
tft.setCursor(0,30);
delay(3000);
tft.fillScreen(Black);
}
if (weather.equals("Cold"))
{
tft.setCursor(0,0);
tft.print("Very Cold");
tft.setCursor(0,30);
tft.print("Move Away");
delay(3000);
tft.fillScreen(Black);
}
}