well im having some problems with this what im trying to do is i have 2pots that are set to differnt values used for the delays. and a switch + 2 realys controling 2 leds.
so what im trying to do if the switch is turnnd on it reads the on delay it delays then the leds turn on.
if the switch gose off it reads the off delay it delays then turns the leds off
but if the switch is off its still reading that delay so if the switch gose on its doing the off delay then gose to the on delay so the delay is too long
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,21);
int potPin = A6; // Potentiometer Pin
int potPin1 = A7; // Potentiometer Pin
int led1 = 5; // Relay 1
int led2 = 6; // Relay 2
int potValue = 0; // variable from the sensor
int potValue1 = 0;
const int buttonPin0 = A0;Â Â
int buttonState0 = 0;Â
void setup() {
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(buttonPin0, INPUT);
 Serial.begin(9600);
 lcd.init();          Â
 lcd.backlight();
 lcd.begin(20, 4);
}
void loop(){
 buttonState0 = digitalRead(buttonPin0);
Â
 potValue = analogRead(potPin);
 potValue = map(potValue, 0, 1023, 1000, 60000);
Â
 potValue1 = analogRead(potPin1);
 potValue1 = map(potValue1, 0, 1023, 1000, 60000);
Â
 lcd.setCursor(7, 0);
 lcd.print("TIMER");
 lcd.setCursor(0, 1);
 lcd.print("ON DELAY:");
 lcd.setCursor(10, 1);
 lcd.print(potValue);
 lcd.print(" ");
 lcd.setCursor(0, 2);
 lcd.print("OFF DELAY:");
 lcd.setCursor(10, 2);
 lcd.print(potValue1);
 lcd.print(" ");
Â
 if (buttonState0 == HIGH) { Â
 Â
  Serial.println("1 ON"); //A0 = DIP 1
  Serial.println(potValue);
  delay(potValue);
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
 Â
 }
 else {
 Â
  Serial.println("1 OFF");
  Serial.println(potValue1);
  delay(potValue1);
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
 Â
 }
}