When answering a question please:
Read the question carefully
Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
The sensor detect an presence of an event and then returns a value as long as there is an object - same as SONAR detect an object then returning "ping".
Call that 'object detected" state.
Next job is to detect an absence of an object - no "ping".
Basically like this
while( object not present ) - wait for an object
while ( object present ) - wait for an absence of object
and when you get this working you can tackle non blocking code version.