Start and stop motion detected

Hello friend, this code is detecting the movement, but it is working all the time. I want to do this in server mode, add a button to it, I want to make the alarm active or passive, I can help the card esp8266 nodemcu

int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
 
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
 
  Serial.begin(9600);
}
 
void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}

ykilicaslan:
I want to do this in server mode, add a button to it, I want to make the alarm active or passive, I can help the card esp8266 nodemcu

Explain what you mean by that? Don't try to use jargon. Just describe what you want it to do.

I want to make the security alarm system, the code is always running this way, I want to bring the status of the alarm to open or closed with an application. the alarm is active, let me work, the alarm is not working when I say the system! i use esp8266 nodemcu

Or, I want to have a web interface to turn the alarm on and off.

samples:

192.168.4.1/alarm?active or passive

Hi

Hi. Your question still doesn't make any sense. I think you should look at the foreign language sections and see if there is one in a language that you speak. Or perhaps find someone who speaks English well to help you rewrite this so that it makes sense.