Using "Falling" Outside of Interrupt

Can you use "falling" outside an interrupt function? I am trying to wright my code so if a pin goes from high to low it performs a command but I'm not having any luck with it at the moment. Here is my code if you can help me out! Thanks!

 if (EstopVal = FALLING) {
   
    if(currentMillis - previousMillis > EstopInterval) {
    previousMillis = currentMillis;
    
    if (EstopLit == LOW)
      EstopLit = HIGH;
    else
      EstopLit = LOW;
    digitalWrite(EstopLT, EstopLit);
  
    }
  else
 if (EstopVal = FALLING) {

For a start, that is assigning, not testing.

You would need to check for a state change, eg.

 if (EstopVal == LOW && previousEstopVal == HIGH) {

Then afterwards remember the previous value for next time:

previousEstopVal = EstopVal;

Where are you reading the state of the pin? Such as:

EstopVal = digitalRead(EstopPin);

FALLING is just a predefined number, to set the behaviour of the interrupt. From wiring.h

#define CHANGE 1
#define FALLING 2
#define RISING 3

So yes you can use FALLING but it would probably not do what you expect. It's just a replacement for the number 3

I am having trouble figuring out where exactly to put the EstopVal = prevEstopVal; command as it seems to mess things up everywhere I've tried placing it. When the program starts the prevEstopVal is already set at LOW and the button will be HIGH.

if (EstopVal == LOW && prevEstopVal == HIGH) {
     
    if(currentMillis - previousMillis > EstopInterval) {
    previousMillis = currentMillis;
    
    if (EstopLit == LOW)
      EstopLit = HIGH;
    else
      EstopLit = LOW;
    digitalWrite(EstopLT, EstopLit);
    }
}
  
  if (EstopVal == HIGH && prevEstopVal == LOW) {...

schoolsterz123:
I am having trouble figuring out where exactly to put the EstopVal = prevEstopVal; command as it seems to mess things up everywhere I've tried placing it. When the program starts the prevEstopVal is already set at LOW and the button will be HIGH.

In the same scope as where you read the button state, but only after you are done comparing.