Run If statement once every time State is High

Hello, everyone. I am trying to run the if statement only one time once I receive a High digitalwrite

I am having two if else statements and I think the logic is correct, but it only run the if statement one time and never runs it again! anyone can catch where is the issue?

bool executed = true;

void loop() {

  // read the state of the signal value
  SignalState = digitalRead(SignalPin);

  if (SignalState == HIGH && executed == true) {
      Serial.println("first loop");
      executed = false;
      String emailMessage = String("An Alarm Detected on the ARBIN system please check it");
      if(sendEmailNotification(emailMessage)) {
        emailSent = true;

      else {
        Serial.println("Email failed to send");
 if (SignalState == LOW)
    executed == true;
    //Serial.println("second loop");


Your code doesn't compile.

it compiles, the first if statement only runs once and when I change state from low to high it doesn't run it again, as the executed didn't change t o true again I think

Here is an obvious issue:

    executed == true;

I didn't get it, the second if statement converts the executed==true; so the first if statement can run again once the signalstate is high.

The StateChangeDetection example is where to look...

the state detection changes correctly, I followed it in the serial monitor and it's fine, I think execute statement is the one that prevent the if from running again

executed == true;

should be

executed = true;

omg :joy: sorry guys for the dumb mistake