/*
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 mlist1 "DC ATS SYSTEM"
uint8_t mode = 0;
#define bt1 8
bool valA1 = 1;
bool valB1 = 1;
void setup() {
tft.begin();
pinMode(bt1, INPUT_PULLUP);
}
void loop() {
valB1 = digitalRead(bt1);
if(mode == 0){
tft.setRotation(3);
tft.setCursor(55, 15);
tft.setTextColor(0xFFE0);
tft.setTextSize(3);
tft.println(mlist1);
if(valA1 == 1 && valB1 == 0){
if(valA1 == 0 && valB1 == 1){
tft.fillScreen(ILI9341_BLACK);
mode = 1;
}
}
valA1 = valB1;
}
if(mode == 1){
tft.setCursor(20, 70);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Volt source 1 12V");
tft.setTextColor(ILI9341_RED);
tft.setCursor(20, 100);
tft.println("Volt source 2 15V");
tft.setCursor(20, 130);
tft.setTextColor(ILI9341_RED);
tft.println("Volt Output 1 15V");
if(valA1 == 1 && valB1 == 0){
if(valA1 == 0 && valB1 == 1){
tft.fillScreen(ILI9341_BLACK);
mode = 0;
}
}
valA1 = valB1;
}
}
*/
#include "SPI.h" // SPI display
#include "Adafruit_GFX.h" // Adafruit graphics
#include "Adafruit_ILI9341.h" // ILI9341 screen controller
float pre_time = 0;
float curr_time = 0;
float secounds = 0.5;
// pin definitions
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft=Adafruit_ILI9341(TFT_CS, TFT_DC); // hardware SPI
int mode = 0;
#define ledstate 7
void setup(){
tft.begin();
pinMode(ledstate, OUTPUT);
tft.setTextWrap(false); // Don't wrap text to next line
tft.setTextSize(1); // large letters
tft.setRotation(4); // horizontal display
}
void loop(){
digitalWrite(ledstate,(millis()/300)%2);
curr_time=millis();
if((curr_time-pre_time) >= 100){
secounds = secounds-0.5;
pre_time=curr_time;
}
if(secounds == 0){
mode++;
secounds = 0.5;
}
if(mode == 3){mode = 0;}
if(mode == 0){
tft.setTextColor(ILI9341_GREEN);
tft.setCursor(50, 50);
tft.print(">>");
tft.setTextColor(ILI9341_BLACK);
tft.setCursor(60, 50);
tft.print(">>");
tft.setCursor(70, 50);
tft.print(">>");
}
if(mode == 1){
tft.setTextColor(ILI9341_GREEN);
tft.setCursor(60, 50);
tft.print(">>");
tft.setTextColor(ILI9341_BLACK);
tft.setCursor(50, 50);
tft.print(">>");
tft.setCursor(70, 50);
tft.print(">>");
}
if(mode == 2){
tft.setTextColor(ILI9341_GREEN);
tft.setCursor(70, 50);
tft.print(">>");
tft.setTextColor(ILI9341_BLACK);
tft.setCursor(50, 50);
tft.print(">>");
tft.setCursor(60, 50);
tft.print(">>");
}
}