int sensorPin = A0; // Analog input pin for the potentiometer
int ledPin = 9; // Digital output pin for the LED
int threshold = 500; // Threshold value for triggering the LED
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600); // For monitoring values
}
void loop() {
int sensorValue = analogRead(sensorPin); // Read potentiometer
Serial.println(sensorValue); // Print value to Serial Monitor
if (sensorValue > threshold) { // Check if above threshold
digitalWrite(ledPin, HIGH); // Turn on LED
} else {
digitalWrite(ledPin, LOW); // Turn off LED
}
delay(100);
}