Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int pinSensor = A5;
- float panjangSensor = 4.0 ;
- void setup() {
- Serial.begin(9600);
- Serial.println("Mengukur Ketinggian Air");
- delay(500);
- }
- void loop() {
- int nilai = analogRead(pinSensor);
- if (nilai == 0) {
- Serial.println("Air tidak terdeteksi");
- } else {
- float tinggiAir = nilai * panjangSensor / 1023;
- Serial.print("Tinggi Air = ");
- Serial.print(tinggiAir);
- Serial.println(" cm");
- Serial.println(nilai);
- }
- delay(5000);
- Serial.println();
- }
Add Comment
Please, Sign In to add comment