On a motor after a continuous input of a certain amount of time
You must store the state of the last readings and do something like this:

    //Off-loop:
    bool state_changed = false;
    unsigned long time_in_state = 0;
    unsigned long last_reading = 0;

    //On-loop:
    if (sensorValue &gt; treshold &amp;&amp; !state_changed) {
        time_in_state += millis() - last_reading;
        last_reading = millis();
    }
    else {
        state_changed = true;
        time_in_state = 0;
    }

    if (time_in_state &gt; TIME_REQUIRED) {
      digitalWrite (3, HIGH);
    }