Coding for Kids

DIY Automatic Door Opener: 10 Easy Steps with micro:bit

DIY Automatic Door Opener: 10 Easy Steps with micro:bit

DIY Automatic Door Opener: 10 Easy Steps with micro:bit

DIY Automatic Door Opener : Complete STEM Project Using BBC Micro:bit, Ultrasonic Sensor and Servo Motor

The DIY Automatic Door Opener is a beginner-friendly STEM project that demonstrates how a Micro:bit can detect an approaching person and control a small door automatically. An ultrasonic sensor measures distance, while a servo motor opens and closes a lightweight model door. The project combines electronics, programming, sensing, mechanical movement and automation in a hands-on activity suitable for classrooms, STEM exhibitions and home learning. 

Innovation

Transforms a simple model doorway into a touch-free automatic entry system. A distance sensor detects an approaching object and the Micro:bit commands a servo motor to open and close the door.

Materials Required

BBC Micro:bit; Micro:bit expansion/breakout board; ultrasonic distance sensor; SG90 or similar servo motor; cardboard/foam board; craft sticks or hinges; jumper wires; suitable battery pack or USB power; computer with Microsoft MakeCode; tape or hot glue; ruler and scissors. DIY Automatic Door Opener: 10 Easy Steps with micro:bit

Learning Objectives

Understand ultrasonic distance sensing; learn how a Micro:bit reads sensor input; understand servo control; practice variables, loops and if-else conditions; explore automation; develop construction, testing, debugging and engineering skills.

Working Principle of Automatic Door Opener

Ultrasonic Sensor → Micro:bit → Decision Making → Servo Motor → Door Movement. The sensor detects how close an object is. The Micro:bit compares the reading with a threshold. If the object is close enough, the servo rotates to open the door; after a delay it returns to the closed position. 

Detailed Step-by-Step Procedure

Step 1: Build the Door Frame — Cut cardboard or foam board to make a small doorway and lightweight door. Attach the door with tape or simple hinges.

Step 2: Mount the Servo — Fix the servo beside the hinge and connect its horn to the door with a small cardboard linkage. Check that the door moves freely.

Step 3: Position the Ultrasonic Sensor — Mount it facing the doorway so it can detect an approaching hand or object.

Step 4: Connect the Sensor — Connect VCC and GND correctly, TRIG to a digital pin such as P1, and ECHO to a suitable input through a Micro:bit-compatible interface.

Step 5: Connect the Servo — Connect the signal wire to a PWM-capable pin such as P0. Use a suitable external supply when required and share ground appropriately.

Step 6: Create the MakeCode Project — Open Microsoft MakeCode and create Automatic Door Opener. Add the appropriate ultrasonic-sensor extension for the hardware being used.

Step 7: Create a Variable — Create Distance and store the ultrasonic reading in it inside Forever.

Step 8: Add Decision Logic — If Distance < 20 cm, set the servo to about 90°; otherwise keep it at 0°.

Step 9: Add a Delay — Keep the door open for about 3000 ms, then return the servo to 0°.

Step 10: Test and Improve — Download the program, approach the sensor, and adjust the distance threshold, servo angles and timing for smooth operation. DIY Automatic Door Opener: 10 Easy Steps with micro:bit

Detailed Block-Based Coding Logic

On Start: Set servo P0 to 0° so the door starts closed.

Forever: Read the ultrasonic sensor and store the value in Distance. If Distance < 20 cm, set servo P0 to 90°, display an open-door icon, pause 3000 ms, and set servo P0 to 0°. Otherwise keep the servo at 0°.

Students can experiment with the distance threshold, opening angle and delay. DIY Automatic Door Opener: 10 Easy Steps with micro:bit

Expected Output

When a person or hand approaches the doorway, the ultrasonic sensor detects the reduced distance. The Micro:bit processes the reading and commands the servo to open the model door. After the programmed delay, the door closes automatically and the system waits for the next approach. DIY Automatic Door Opener: 10 Easy Steps with micro:bit DIY Automatic Door Opener: 10 Easy Steps with micro:bit DIY Automatic Door Opener: 10 Easy Steps with micro:bit

Applications

Touch-free classroom and laboratory models; smart-home automation demonstrations; automatic entrance systems; accessibility concepts; hospital and public-building models; robotics and IoT learning; STEM exhibitions and science-fair projects. DIY Automatic Door Opener: 10 Easy Steps with micro:bit

Advantages

Touch-free and interactive; combines sensing, coding and mechanical movement; uses beginner-friendly block coding; easy to build with inexpensive materials; expandable with LEDs, buzzers, RFID, buttons or additional sensors.

Safety Precautions

Use suitable low-voltage power supplies. Do not force the servo when the door is blocked. Use an external supply if the servo needs more current than the Micro:bit can provide. Check wiring before powering. Keep fingers clear of moving parts. Switch off power before changing connections. Use adult supervision for scissors and hot glue.

Conclusion

The DIY Automatic Door Opener connects sensor technology, programming and mechanical automation in one practical STEM activity. Students learn how an ultrasonic sensor detects an approaching object and how a Micro:bit converts that information into servo movement. By changing the threshold, opening angle and timing, learners can test, debug and improve their design while building a foundation for smart-home systems, assistive technology and robotics.

Frequently Asked Questions (FAQs)

1. What is a DIY automatic door opener?

A DIY automatic door opener is a model system that uses a sensor to detect an approaching object and a motor to automatically open a lightweight door.

2. Which sensor is used in this Automatic Door Opener project?

The project uses an ultrasonic distance sensor to detect how close an object is to the doorway.

3. Why is a servo motor used?

A servo motor can rotate to a controlled position, making it suitable for opening and closing a small model door.

4. Can I use a different servo motor?

Yes, provided the servo is electrically compatible with your setup and has enough torque to move the lightweight model door.

5. Can I add other sensors?

Yes. You can experiment with PIR sensors, buttons, RFID systems or other compatible inputs.

6. Is this Automatic Door Opener project beginner-friendly?

Yes. The cardboard model and block-based MakeCode programming make it suitable as a beginner STEM project with appropriate supervision.

Real Projects, Real Results

From hands-on learning to competition wins—see what Chitti students achieve

Find a class near you

Pick your city, district or county. Each page has local class times, kit shipping notes, and a trial button for families in that place.

India & US cities

India states

United States states