turn off fet after 10 sec ?

Hi friends. I want to turn off the smsfet defined pin after 10 seconds in the blow sketch but not success. can anyone help me to fix ? thanks

#include <avr/sleep.h>
#include <avr/interrupt.h>

#define TURN_ON_FET     0
#define MONITOR_SENSOR  1
#define FLASH           2
#define FETS           3

const byte voltageSensor = 0;
const byte flasherSwitch = 1;
const byte smsfet = 2;
const byte reedSwitch = 3;
const byte MOSFET = 4;

void setup()
{
  pinMode( reedSwitch, INPUT );
  pinMode( voltageSensor, INPUT );
  pinMode( MOSFET, OUTPUT );
  pinMode( flasherSwitch, OUTPUT );
  pinMode( smsfet, OUTPUT );
  sleep();
}

void loop()
{
  unsigned long timeNow;
  static unsigned long timeFunc;
  static byte state = TURN_ON_FET;
  timeNow = millis();
  switch ( state )
  {
    case    TURN_ON_FET:
      digitalWrite( smsfet, HIGH );
      digitalWrite( MOSFET, HIGH );
      delay(5000);
      timeFunc = timeNow;
      state = MONITOR_SENSOR;
      break;
    case    MONITOR_SENSOR:
      if ( digitalRead(voltageSensor) == HIGH )
      {
        digitalWrite( MOSFET, LOW );
        state = TURN_ON_FET;
        digitalWrite( smsfet, LOW );
        sleep();
      }
      else if ( (timeNow - timeFunc) >= 3000ul )
      {
        digitalWrite( flasherSwitch, HIGH );
        timeFunc = timeNow;
        state = FLASH;
      }
      break;
    case    FLASH:
      if ( timeNow - timeFunc >= 50ul )
      {
        digitalWrite( flasherSwitch, LOW );
        timeFunc = timeNow;
        state = MONITOR_SENSOR;
      }
      break;
    case    FETS:
      if ( (timeNow - timeFunc) >= 10000ul )
      {
        digitalWrite( smsfet, LOW );
      }
      
  }
}

  void sleep() {
    GIMSK |= _BV(PCIE);
    PCMSK |= _BV(PCINT3);
    ADCSRA &= ~_BV(ADEN);
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    sleep_enable();
    sei();
    sleep_cpu();
    cli();
    PCMSK &= ~_BV(PCINT3);
    sleep_disable();
    ADCSRA |= _BV(ADEN);
    sei();
  }
  ISR(PCINT0_vect) {
  }

it looks like your FETS case is correct.
do you get there? I don't see "state = FETS;" anywhere

and what state should you go to from FETS?

gcjr:
it looks like your FETS case is correct.
do you get there? I don't see "state = FETS;" anywhere

and what state should you go to from FETS?

thanks for reply. I don't know exactly where to put state =FETS; I put it in the FETS case but not working.

ErfanDL:
thanks for reply. I don't know exactly where to put state =FETS; I put it in the FETS case but not working.

you have to put it one of the other states.
when do you want to turn off the fet

gcjr:
you have to put it one of the other states.
when do you want to turn off the fet

is any way to do it without state ?

yes

when do you want to turn it off?

gcjr:
yes

when do you want to turn it off?

just after 10 second when I powering the arduino. but I don't need delay I want to run it in the loop with millis.

thanks.

I solved the problem with correct state setup.
thanks.