/*
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_OLIVE 0x7BE0 /* 128, 128, 0 */
#define TFT_DC 48
#define TFT_CS 40
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
const int buttonPin = 0;
const int relayPin = 25;
int oldValue = HIGH; // default/idle value for pin 0 is high.
void setup() {
pinMode(relayPin, OUTPUT);
Serial.begin(115200);
Serial.println("Press the button.");
pinMode(buttonPin, INPUT);
tft.begin();
tft.setRotation(3);
tft.setCursor(5, 5);
tft.setTextColor(TFT_OLIVE);
tft.setTextSize(3);
tft.println("Hydrostation is OFF");
tft.setCursor(20, 160);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
//tft.println("I can has colors?");
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
void loop() {
int newValue = digitalRead(buttonPin);
if (newValue != oldValue)
{
if (newValue == LOW)
{
tft.println("The button is pressed.");
digitalWrite(relayPin,HIGH);
}
else
{
tft.println("The button is released.");
}
oldValue = newValue;
}
delay(100);
}
/*
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 48
// #define TFT_CS 53
// Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// void setup() {
// tft.begin();
// tft.setCursor(26, 120);
// tft.setTextColor(ILI9341_RED);
// tft.setTextSize(3);
// tft.println("Hello, TFT!");
// tft.setCursor(20, 160);
// tft.setTextColor(ILI9341_GREEN);
// tft.setTextSize(2);
// tft.println("I can has colors?");
// // Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
// }
// void loop() { }