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