Sense → decide → act
The infrared sensor does not open the door by itself. It only measures how far away a person is. That number is sent continually to a microprocessor.
The microprocessor compares each new reading with a threshold of 1.0 metre. Within range → send an open signal. Farther away → keep the door closed (or close it).
THRESHOLD = 1.0 while True: distance = ir_sensor.read() if distance <= THRESHOLD: door.open() else: door.close()
Watch packets labelled with metres fly from the sensor to the chip.
Run the simulation
Watch the person approach, then follow the icons: sensor → microprocessor → motor. Blue packets carry distance; green/red packets carry the door command.
What this system teaches
Continuous sensing, a simple rule, and an actuator.
Data keeps flowing
The IR sensor samples distance in a loop. Each value is a message to the microprocessor — not a one-off event.
Compare to a threshold
The chip asks: is distance ≤ 1.0? That boolean choice picks the next action.
Signal the door
Only after the decision does the microprocessor send open or close to the door mechanism.