#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 9
#define TFT_CS 10
#define HIGH (1)
#define LOW (0)
const int pt1=A0;
const int pt2=A1;
const int rly1=3;
const int llc=391;
const int ulc=421;
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
Serial.begin(115200);
pinMode(A0, INPUT);
pinMode(A2, INPUT);
pinMode(3, OUTPUT);
tft.begin();
tft.setCursor(1, 2);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("RAM Air Ride System!");
tft.setCursor(1, 60);
tft.setTextColor(ILI9341_ORANGE);
tft.setTextSize(1);
tft.println("Tank Pressure");
tft.setCursor(1, 160);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(1);
tft.println("Air Bag Pressure");
tft.setCursor(200,100);
tft.setTextColor(ILI9341_ORANGE);
tft.setTextSize(2);
tft.println("PSI");
tft.setCursor(200, 200);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("PSI");
}
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
void loop() {
int pt1=analogRead(A0);
tft.setCursor (22, 80);
tft.setTextColor(ILI9341_ORANGE);
tft.setTextSize(5);
tft.println(pt1 *.16617);
delay(15);
tft.setCursor (22, 80);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(5);
tft.println(pt1 *.16617);
delay(1);
int pt2=analogRead(A1);
tft.setCursor (22, 180);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(5);
tft.println(pt2 *.16617);
delay(15);
tft.setCursor (22, 180);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(5);
tft.println(pt2 *.16617);
delay(1);
if(pt1 > ulc) {
digitalWrite(rly1, LOW);
}
if(pt1 < llc){
digitalWrite(rly1, HIGH);
}
}