void setup() {
Serial.begin(9600);
pinMode(2, INPUT);
pinMode(8, OUTPUT);
}
void loop() {
int sensor1 = digitalRead(2);
if (sensor1 == LOW) {
Serial.print("Sensor 1: 1 | "); // Print 1 when the sensor is LOW (indicating light is on)
Serial.println("menyala lampuku");
digitalWrite(8, HIGH);
} else {
Serial.print("Sensor 1: 0 | "); // Print 0 when the sensor is HIGH (indicating light is off)
Serial.println("mati lampuku");
digitalWrite(8, LOW);
}
delay(100);
}