#define waterLevelP 15
#define relayP1 2
#define relayP2 4
int waterLevel = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(waterLevelP, INPUT);
pinMode(relayP1, OUTPUT);
pinMode(relayP2, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
waterLevel = analogRead(15);
Serial.println(waterLevel);
if (waterLevel < 1000) {
digitalWrite(relayP1, LOW);
}
else {
digitalWrite(relayP1, HIGH);
}
delay(100);
digitalWrite(relayP2, HIGH);
delay(200);
digitalWrite(relayP2, LOW);
}