//ada dua tombol,tombol bawah mendeteksi air lvl bawah,atas mendeteksi air lvl atas,
//mendeteksi lvl air paada tangki air/lvl air dri sebuah sungai
//maksudnya gini kalau air pada lvl bawah maka switch tertekan
//keluar tampilan status normal
//air naik tekan switch atas
//buzzer berbunyi dan tampil di lcd dan kondisi air
//buzzer berbunyi pada saat lvl ats "berbahaya"
//air bawah hanya tampilan lcd
#include<LiquidCrystal_I2C.h>
#include<Wire.h>
#define satas 27
#define sawah 26
#define buzz 25
LiquidCrystal_I2C lcd(0x27,16,2);
int switchState = 0;
int switchState1 = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Hello, ESP32!");
pinMode(satas, INPUT_PULLUP);
pinMode(sawah, INPUT_PULLUP);
pinMode(buzz, OUTPUT);
lcd.init();
lcd.backlight();
}
void loop() {
// put your main code here, to run repeatedly:
// this speeds up the simulation
switchState = digitalRead(satas);
switchState1 = digitalRead(sawah);
if( switchState == LOW ){
lcd.clear();
tone (buzz,500);
digitalWrite(buzz,OUTPUT);
lcd.setCursor(4, 0);
lcd.print("DANGER");
}
if(switchState1 == LOW)
{
lcd.clear();
noTone(25);
lcd.setCursor(4, 0);
lcd.print("NORMAL");
}
}