Welcome to Building:bit Superkit repository
3.8 Automatic safety door
Automatic safety door
Automatic safety door1. Learning objectives2. Building blocks3. Sensor wiring4. Programming4.1 Add expansion package4.2 Building blocks used4.3 Combination blocks5. Experimental phenomenon
1. Learning objectives
In this course, we mainly learn how to make color recognition security automatic doors through MakeCode graphical programming.
2. Building blocks
For detailed steps of building blocks, please refer to the installation drawings of [Assembly Course]--[Color-recognition automatic door] or the building blocks installation album in the materials.
3. Sensor wiring
Insert the building block servo wiring into the S1 interface of the Super:bit expansion board, and the orange servo wiring into the yellow pin of S1.
The color recognition module is connected to the I2C (SDA, SCL) interface.

! Notes:
When taking the course related to the building block servo for the first time, we need to remove the blue building block installed on the servo and upload the program of this course to the micro:bit; then turn on the power switch of the Super:bit expansion board and wait for the building block servo to turn to the initial position; then, we can turn off the power, adjust the security automatic door to the open state, as shown in the figure below, and then install the blue building block. (If you have used the security automatic door and servo related program before, you can skip this step)

4. Programming
Method 1 Online Programming:
First, connect the micro:bit to the computer via a USB data cable, and a U disk will pop up on the computer. Click the URL in the U disk: https://makecode.microbit.org/ to enter the programming interface. Then, add the Yahboom software package to program.
Method 2 Offline Programming:
Open the offline programming software MakeCode and enter the programming interface. Click [New] and add the Yahboom software package to start programming.
superbit kit expansion package: https://github.com/YahboomTechnology/SuperBitLibV2 Color recognition sensor: https://github.com/YahboomTechnology/module_world_color
4.1 Add expansion package


4.2 Building blocks used
The location of the building blocks required for this programming is shown in the figure below.




4.3 Combination blocks
For detailed procedures, please drag the Automatic-safety-door.hex file provided in this experiment into the browser that opens the URL to view, and the program diagram of this project source code will be automatically opened.
5. Experimental phenomenon
After the program runs successfully, the servo is initialized to 0°. When the color sensor recognizes blue, the door will open and the microbit dot matrix will display "smiley face". It will close the door after two seconds. For other colors, the door will not open and the microbit dot matrix will display "asleep".