const int potPin = A4;
const int relayPin = 2;
void setup() {
pinMode(potPin, INPUT);
pinMode(relayPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int potValue = analogRead(potPin);
int relayValue = map(potValue, 0, 1023, 0, 255);
if (relayValue > 128) {
digitalWrite(relayPin, HIGH);
digitalWrite(relayPin, LOW);
Serial.println(relayValue);
delay(100);
}
}