const int analogInputPin = A0;
const int ledPin = 12;
int sensorValue = 0;
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}
void loop() {
sensorValue = analogRead(analogInputPin);
Serial.print("DO SANG LED : ");
Serial.println(sensorValue);
if (sensorValue >= 1000 && sensorValue < 2500) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
else if (sensorValue >= 3500 ) {
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
}