//Projek 06 - Relay potensio
//Nama : ULLY KEYSA RAHMA
//Kelas : XII PPLG B
//Tanggal : 30/07/2024
const int potPin = A0;
const int ledPin = 8;
const int relayPin = 7;
const int thresholdLow = 100;
const int thresholdHigh = 900;
void setup() {
pinMode(potPin, INPUT);
pinMode(relayPin, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int potValue = analogRead(potPin);
Serial.print("Nilai Potentiometer: ");
Serial.println(potValue);
if (potValue < thresholdLow) {
digitalWrite(relayPin, HIGH);
digitalWrite(ledPin, HIGH);
Serial.println("Pompa Hidup");
} else if (potValue > thresholdHigh) {
digitalWrite(relayPin, LOW);
digitalWrite(ledPin, LOW);
Serial.println("Pompa Mati");
}
delay(1000);
}