const int potPin = A0; // Potentiometer input pin
const int ledPin = 2; // LED output pin
int targetValue = 512; // The target value for the potentiometer
int tolerance = 10; // Tolerance for timing
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(potPin);
Serial.println(sensorValue);
if (abs(sensorValue - targetValue) <= tolerance) {
digitalWrite(ledPin, HIGH); // Turn on the LED when timing is right
} else {
digitalWrite(ledPin, LOW); // Turn off the LED when timing is wrong
}
}