// Define pin numbers for relay control and potentiometer
const int relayPin = 2; // Change this to the GPIO pin you're using for relay control
const int potPin = 34; // Change this to the GPIO pin you're using for the potentiometer
void setup() {
// Set the relay pin as an output
pinMode(relayPin, OUTPUT);
}
void loop() {
// Read the value from the potentiometer
int potValue = analogRead(potPin);
// Check if the potentiometer is halfway turned (approximately)
if (potValue > 1000 - 50 && potValue < 1000 + 50) {
// Turn on the relay
digitalWrite(relayPin, HIGH);// Wait for 500 milliseconds
}
else{
digitalWrite(relayPin, LOW); // Wait for 500 milliseconds
}
}