int sensor = A0;
int nilaisensor = 0;
int PIN = 13;
void setup() {
Serial.begin(9600);
pinMode(PIN, OUTPUT);
}
void loop() {
nilaisensor = analogRead(sensor);
Serial.print("Data yang terbaca :");
Serial.println(nilaisensor);
if(analogRead(sensor) >= 500){
digitalWrite(PIN, HIGH);
}
else{
digitalWrite(PIN, LOW);
}
}