Codingan Kontrol Level Tanki Air Dengan Arduino
#define ECHOPIN 10
#define TRIGPIN 11
#define pompa 12
int H2,HT,H1,SPH,SPL;
void setup(){ pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
pinMode(pompa, OUTPUT);
delay(1000);
HT=200;
SPH=150;
SPL=50;
}
void loop(){
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGPIN, LOW);
int distance = pulseIn(ECHOPIN, HIGH);
distance= distance/58;
H2=HT-distance;
if(H2
digitalWrite(pompa,HIGH);
}
else if (H2>SPH){
digitalWrite(pompa,LOW);
}
delay(1000);
}
Sumber : http://inkubator-teknologi.com/kontrol-level-air-dengan-arduino/
Tidak ada komentar:
Posting Komentar