// Define analog input pin and LED pin
const int analogPin = A0;
const int ledPin = 13;
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Set LED pin as output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read analog input value
int sensorValue = analogRead(analogPin);
// Print the value for debugging
Serial.println(sensorValue);
// Check if the value is within the specified range
if (sensorValue >= 300 && sensorValue <= 700) {
// Blink the LED with a period of 2 seconds on and off
digitalWrite(ledPin, HIGH);
delay(2000);
digitalWrite(ledPin, LOW);
delay(2000);
} else if (sensorValue > 700) {
// Turn on the LED continuously
digitalWrite(ledPin, HIGH);
} else {
// Turn off the LED if the value is less than 300
digitalWrite(ledPin, LOW);
}
}