add new water level
This commit is contained in:
parent
33bdfed478
commit
9429ead6f1
@ -177,6 +177,13 @@ void setup(void) {
|
|||||||
pinMode(5, OUTPUT);
|
pinMode(5, OUTPUT);
|
||||||
digitalWrite(5, HIGH);
|
digitalWrite(5, HIGH);
|
||||||
pinMode(9, INPUT_PULLUP);
|
pinMode(9, INPUT_PULLUP);
|
||||||
|
|
||||||
|
// water level pins
|
||||||
|
pinMode(34, INPUT_PULLUP);
|
||||||
|
pinMode(35, INPUT_PULLUP);
|
||||||
|
pinMode(36, INPUT_PULLUP);
|
||||||
|
pinMode(37, INPUT_PULLUP);
|
||||||
|
|
||||||
setTime(0);
|
setTime(0);
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
dht.begin();
|
dht.begin();
|
||||||
@ -353,6 +360,7 @@ void loop(void) {
|
|||||||
drawButton(0, 20, 320, 220, "", ILI9341_WHITE);
|
drawButton(0, 20, 320, 220, "", ILI9341_WHITE);
|
||||||
drawButton(160, 130, 160, 110, "Back", ILI9341_BLUE);
|
drawButton(160, 130, 160, 110, "Back", ILI9341_BLUE);
|
||||||
drawUD(uda);
|
drawUD(uda);
|
||||||
|
displayText(10, 20, false, "Water amount:", 2);
|
||||||
}
|
}
|
||||||
upd = false;
|
upd = false;
|
||||||
}
|
}
|
||||||
@ -445,26 +453,23 @@ void checkBat() {
|
|||||||
tft.drawString(out.c_str(), 162, 2, 2);
|
tft.drawString(out.c_str(), 162, 2, 2);
|
||||||
}
|
}
|
||||||
// check water level
|
// check water level
|
||||||
// A15: Top
|
// A37: Top
|
||||||
// A13: Bottom
|
// A34: Bottom
|
||||||
// 47: Power
|
if (digitalRead(34) == 0) drawButton(140, 2, 16, 16, "", ILI9341_RED);
|
||||||
digitalWrite(47, HIGH);
|
if (digitalRead(35) == 0) drawButton(140, 2, 16, 16, "", ILI9341_ORANGE);
|
||||||
int a = checkPin(15, 20);
|
if (digitalRead(36) == 0) drawButton(140, 2, 16, 16, "", ILI9341_YELLOW);
|
||||||
int b = checkPin(14, 20);
|
if (digitalRead(37) == 0) drawButton(140, 2, 16, 16, "", ILI9341_GREEN);
|
||||||
int c = checkPin(13, 20);
|
|
||||||
digitalWrite(47, LOW);
|
|
||||||
if(c > 200) drawButton(140, 2, 16, 16, "", ILI9341_RED);
|
|
||||||
if(b > 200) drawButton(140, 2, 16, 16, "", ILI9341_YELLOW);
|
|
||||||
if(a > 200) drawButton(140, 2, 16, 16, "", ILI9341_GREEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int checkPin(int pin, int count) {
|
int checkPin(byte pin, int count) {
|
||||||
int out = 0;
|
int out = 0;
|
||||||
for (int x = 0; x < count, x++) {
|
for (int x = 0; x < count; x++) {
|
||||||
out += analogRead(pin);
|
out += analogRead(pin);
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
return out / count;
|
out /= count;
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWater() {
|
void runWater() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user