// Materi 2: Water Level
#define pinSw1 13
#define pinSw2 12
#define pinSw3 14
#define pinLed_Hijau 18
#define pinLed_Kuning 19
#define pinLed_Merah 23
int State_Sw1, State_Sw2, State_Sw3;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(pinSw1, INPUT_PULLUP);
pinMode(pinSw2, INPUT_PULLUP);
pinMode(pinSw3, INPUT_PULLUP);
pinMode(pinLed_Hijau, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
State_Sw1 = digitalRead(pinSw1);
State_Sw2 = digitalRead(pinSw2);
State_Sw3 = digitalRead(pinSw3);
if (State_Sw1 == LOW){
Serial.println("Sw1 Low Level");
digitalWrite(pinLed_Hijau, LOW);
}
else{
digitalWrite(pinLed_Hijau, HIGH); // OFF
}
//---------------------------------------------------------
if (State_Sw2 == LOW){
Serial.println("Sw2 Medium Level");
digitalWrite(pinLed_Kuning, LOW);
}
else{
digitalWrite(pinLed_Hijau, HIGH); // OFF
}
//=========================================================
delay(2000); // this speeds up the simulation
}