I need alternative solution instance while loop ..Any other event / function ?

const int PIN_BUTTON = 10;
int doorstatus = HIGH; // Door status, default High status

void setup() {
pinMode(10, INPUT_PULLUP);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}

void loop() {
doorLockFunction();
}

void doorLockFunction(){
while (1) {
doorstatus = digitalRead(PIN_BUTTON);
if (doorstatus == LOW) {
Serial.print("Door Lock Status :");

digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second

break;
}

}
}

I need alternative solution

instance while loop ..Any other event / function are there .. ?

Here as a public service is the OP's code control-T'd and code tagged.

I suggested to the mods that it get moved: this is surely the wrong board (edit; I see it's been moved)

const int PIN_BUTTON = 10;
int doorstatus = HIGH;  // Door status, default High status

void setup()
{
  pinMode(10, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  doorLockFunction();
}

void doorLockFunction()
{
  while (1)
  {
    doorstatus = digitalRead(PIN_BUTTON);
    if (doorstatus == LOW)
    {
      Serial.print("Door Lock Status :");

      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);                       // wait for a second
      digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);                       // wait for a second

      break;
    }
  }
}

@OP Would you tell us why you wrote this function as you did?

doorLockFunction() :o

larryd:
@OP Would you tell us ....

.... what it's actually supposed to do?

Yes .. your correct .. bcos it will run from the main loop function itself ..

please think we wrote large program .. so, we used separate function for user closed the door or not

For that i connected pin no 10 for input signal.

My queries is please think we have only one function[Forget main loop] . on that without using While Loop can we get solutions ?

What exactly do you want the function to do ?
Is it OK if the function blocks the rest of the program from running or is that the problem ?

in the function ...

Arduino has to received Door close signal[pin no 10].

Till that Arduino has to wait there, For that im using While loop,

My Queries, is there any alternative solution to avoid While loop ?

This seems like an ideal application for a state machine.

If you do not want the program to wait in the function and block other code execution then you cannot use a while. Why not use an if instead and call the function each time through loop() when you need to check the status of the door ?

As AWOL suggest, a state machine sounds like it fits the bill

Thank you nice response

in the doorLockFunction()??

if we remove While loop .. what will happen ?

please let we know, did you know some other alternative ..

Example alternative solutions ==> attachInterrupt()

please tell some other alternative

premnath:
please tell some other alternative

Alternative to what?

So far you've been asked twice....

meltDown:
.... what it's actually supposed to do?

UKHeliBob:
What exactly do you want the function to do ?

.... but haven't answered.

So let me ask you again: what is that function actually supposed to do?

How can anybody advise if the requirement is unclear?

Thank you so much, Give some time, i will tell my requirement clearly

“if we remove While loop .. what will happen ? ”

You can answer this by trying it.

larryd:
You can answer this by trying it.

Way too simple....