#define PIN_TRIG 11
#define PIN_ECHO 10
#define V1 12
#define Bomba 9
#define V3 8
#define V2 7
#define SHS1 2
#define SHS2 4
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(PIN_TRIG, OUTPUT);
pinMode(PIN_ECHO, INPUT);
pinMode(V1, OUTPUT);
pinMode(Bomba, OUTPUT);
pinMode(V3, OUTPUT);
pinMode(V2, OUTPUT);
pinMode(SHS1, INPUT);
pinMode(SHS2, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(PIN_TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(PIN_TRIG, LOW);
int tRecorrido = pulseIn(PIN_ECHO, HIGH);
int nivel = tRecorrido / 58;
int hA = digitalRead(SHS1);
int hB = digitalRead(SHS2);
if(nivel>=399)
{digitalWrite(V1, HIGH);}
if(nivel<=10)
{digitalWrite(V1, LOW);}
if(nivel<=10 & hA==HIGH)
{digitalWrite(V2, HIGH);}
if(nivel>=398 | hA==LOW)
{digitalWrite(V2, LOW);}
if(nivel<=10 & hB==HIGH)
{digitalWrite(V3, HIGH);}
if(nivel>=398 | hB==LOW)
{digitalWrite(V3, LOW);}
if(nivel<=10 & hA==HIGH | hB==HIGH)
{digitalWrite(Bomba,HIGH);}
if(nivel>=398 | hA==LOW & hB==LOW)
{digitalWrite(Bomba,LOW);}
}