3.25 Auto-door

3.25.1 Overview

Many shopping malls open their doors when someone approaches and close them when no one is detected. Herein, we adopt a PIR motion sensor to simulate this kind of auto-door. The door opens when someone is detected and closes when no one is present.

3.25.2 Test Code

3.25.2.1 Code Flow

6-25-2-1

3.25.2.2 Build Code

There are two ways to upload the code: directly open the code file we provide; or manually build blocks.

Directly open the code file we provide:

  1. Click and choose Load from your computer

  1. We have already downloaded the codes on computer desktop, so open the file and choose 3-25-InductionDoor.sb3

Manually build blocks:

  1. Build the two basic blocks:6-1-4-1-1

  2. Drag j16 to determine the output of PIR motion sensor. If a motion is detected, it will output 1. Otherwise, it outputs 0.

  3. When someone is sensed, the servo rotates to 180 degree to open the door. If nothing is detected, the it rotates to 0 degree to close the door.

6-1-4-1-1

Complete Test Code

6-25

3.25.2.3 Test Result

After uploading code, wave your hand over the PIR motion sensor, and the servo will rotate to 180 degree (door open). After a while, it will back to 0 degree (door close) if nothing is detected.