int sensorPin = A0;
int sensorValue = 0;
int threshold = 500;
void setup() {
Serial.begin(9600);
pinMode(sensorPin, INPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
// Print the analog value
Serial.print("Sensor Value: ");
Serial.print(sensorValue);
Serial.print(" | Binary: ");
// Print binary representation based on threshold
if (sensorValue > threshold) {
Serial.println("1 (menyala lampuku)"); // Light is on
} else {
Serial.println("0 (mati lampuku)"); // Light is off
}
delay(500);
}