Anda di halaman 1dari 6

Alat Pengukur Ketinggian Air

1. Hendy Muria
2. Lulut Setiawan
3. Shofian
4. Wanda Pratiwi
Arduino UNO

LED

SOIL MOISTURE HYGROMETER MODULE/


SENSOR KELEMBABAN TANAH ARDUINO
Arduino

#define sensor1 5
#define sensor2 6
#define sensor3 7

#define ledHijau 13
#define ledKuning 12
#define ledMerah 11

#define pompa 10

int condSensor1;
int condSensor2;
int condSensor3;

void setup() {
//pin mode sensor
pinMode(sensor1, INPUT);
pinMode(sensor2, INPUT);
pinMode(sensor3, INPUT);

//pin mode led dan pompa

pinMode(ledMerah, OUTPUT);
pinMode(ledKuning, OUTPUT);
pinMode(ledHijau, OUTPUT);
pinMode(pompa, OUTPUT);

Serial.begin(115200);
if(condSensor1 == 0 && condSensor2 == 0 && condSensor3 == 1){
Serial.println("Ketinggian air sedang");
digitalWrite(ledMerah, LOW);
digitalWrite(ledKuning, HIGH);
digitalWrite(ledHijau, LOW);

}
if(condSensor1 == 0 && condSensor2 == 0 && condSensor3 == 0){
Serial.println("Air penuh");
digitalWrite(ledMerah, LOW);
} digitalWrite(ledKuning, LOW);
digitalWrite(ledHijau, HIGH);
void loop() {
//kondisi dari masing masing sensor }
condSensor1 = digitalRead(sensor1); if(condSensor1 == 1 && condSensor2 == 1 && condSensor3 == 1){
condSensor2 = digitalRead(sensor2); Serial.println("Mengisi air...");
condSensor3 = digitalRead(sensor3); digitalWrite(ledMerah, HIGH);
digitalWrite(ledKuning, LOW);
digitalWrite(ledHijau, LOW);
//print ke serial monitor di arduino ide
Serial.print(condSensor1); }
Serial.print(condSensor2);
Serial.println(condSensor3); /*if (Serial.available())
{
int inputdata = Serial.read();
//if statment if (inputdata=='b')
if(condSensor1 == 0 && condSensor2 == 1 && condSensor3 == 1){ {
//print ke serial monitor di arduino ide digitalWrite(pompa,HIGH);
Serial.println("Air Hampir Habis"); }
else if(inputdata=='a')
digitalWrite(ledMerah, HIGH);
{
digitalWrite(ledKuning, LOW); digitalWrite(pompa,LOW);
digitalWrite(ledHijau, LOW); }
} }
*/

}
VB

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button1.Click
SerialPort1.BaudRate = Val(TextBox1.Text)
SerialPort1.PortName = TextBox2.Text
SerialPort1.Open()
SerialPort1.Write("b")
PictureBox1.BackColor = Color.Green
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button2.Click
SerialPort1.Close()
PictureBox1.BackColor = Color.Black
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button3.Click
SerialPort1.Write("a")
End Sub
End Class
Terimakasih….