10 second timer help

hi,

I need to start a timer when an input is turned low (pin33). If that input is kept low for 10 seconds some action need to be get done. (pin10 HIGH)

Simple right. Well, I got the logic confused. need help in putting Start millis() and Current millis() at right places in the code.

unsigned long startMillis;  
unsigned long currentMillis;
const unsigned long period = 10000;  //10 second time period 
const byte Relay1 = 10;    //Relay pin

const int inputPin = 33;  // switch input
void setup()
{
  Serial.begin(115200);  
  pinMode(Relay1, OUTPUT);
  pinMode(inputPin, INPUT_PULLUP);
  startMillis = millis();  //initial start time
}

void loop()
{
  int inputStatus = digitalRead (inputPin);

  Serial.print(startMillis);
  Serial.print("   ");
  Serial.print(currentMillis);
  Serial.print("   ");
  Serial.println(inputStatus);

  if (inputStatus == HIGH) {
    startMillis = currentMillis;  //If swich HIGH counter reset
    digitalWrite(Relay1, LOW);
  }

  if (inputStatus == LOW) {
    currentMillis = millis();  //If swich LOW timer start
  }

  if (currentMillis - startMillis >= period)  //test whether the period has elapsed
  {
    digitalWrite(Relay1, HIGH);  //if so, change relay status. 

  }
}

I need to start a timer when an input is turned low

This does the opposite, except that most people would use millis() instead of currentMillis.

  if (inputStatus == HIGH) {
    startMillis = currentMillis;  //If swich HIGH counter reset

Good tutorial at Blink without delay() explained line-by-line

It is best to look at when a switch changes state than the level.
You should scan your switches every ~50ms to remove debounce problems.

unsigned long lastMillis;
unsigned long startMillis;
const unsigned long period = 10000ul;  //10 second time period
const byte Relay1          = 10;    //Relay pin
const int inputPin         = 33;  // switch input
byte lastInputStatus;
boolean timingFlag = false;


//****************************************************************************
void setup()
{
  Serial.begin(115200);
  pinMode(Relay1, OUTPUT);
  pinMode(inputPin, INPUT_PULLUP);
  lastInputStatus = digitalRead(inputPin);
}


//****************************************************************************
void loop()
{
  //***************************
  //is timing enabled and has the period expired?
  if (timingFlag == true && millis() - startMillis > period)
  {
    digitalWrite(Relay1, HIGH);
    //disable timing
    timingFlag = false;
  }

  //***************************
  //time to check the switches? 
  if (millis() - lastMillis >= 50)
  {
    lastMillis = millis();
    checkSwitches();
  }

} //END of loop()

//****************************************************************************
void checkSwitches()
{
  int inputStatus = digitalRead (inputPin);

  //Has switch changed state?
  if (lastInputStatus != inputStatus)
  {
    //Yes it has, update to the state
    lastInputStatus = inputStatus;

    //is the switch LOW?
    if (inputStatus == LOW)
    {
      //time the switch went LOW
      startMillis = millis();
      //enabling timing
      timingFlag = true;
    }

    //the switch must have gone HIGH then
    else
    {
      digitalWrite(Relay1, LOW);  // <-----<<<<  remove this line for relay to stay as is
      //disable timing
      timingFlag = false;
    }
  }
  
} //END of checkSwitches()

//****************************************************************************