const int buttonPin1 = 2;  // First push button connected to digital pin 2
const int buttonPin2 = 3;  // Second push button connected to digital pin 3
const int relayPin1 = 7;   // First relay control connected to digital pin 7
const int relayPin2 = 8;   // Second relay control connected to digital pin 8
const int potPin = A0;     // Potentiometer connected to analog pin A0

bool relay1Active = false;
bool relay2Active = false;
unsigned long relay1StartTime = 0;
unsigned long relay1Duration = 0;

void setup() {
  pinMode(buttonPin1, INPUT_PULLUP);
  pinMode(buttonPin2, INPUT_PULLUP);
  pinMode(relayPin1, OUTPUT);
  pinMode(relayPin2, OUTPUT);
  pinMode(potPin, INPUT);
}

void loop() {
  int potValue = analogRead(potPin);  // Read the potentiometer value
  relay1Duration = map(potValue, 0, 1023, 1000, 10000);  // Map the pot value to the desired time range (1s to 10s)

  if (digitalRead(buttonPin1) == LOW) {
    relay1Active = true;
    relay1StartTime = millis();
    digitalWrite(relayPin1, HIGH);
    delay(100);  // Debounce delay
  }

  if (relay1Active) {
    if (millis() - relay1StartTime >= relay1Duration) {
      digitalWrite(relayPin1, LOW);
      relay1Active = false;
    }
  }

  if (digitalRead(buttonPin2) == LOW) {
    relay2Active = !relay2Active;  // Toggle the state
    digitalWrite(relayPin2, relay2Active ? HIGH : LOW);
    delay(100);  // Debounce delay
  }
}
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module