Example Code for micro:bit-MakeCode-Remote Entrance Guard System
This article demonstrates how to set up a remote entrance guard system using a micro:bit and IoT technology. It provides detailed guidance on hardware and software preparation, wiring, and programming with Makecode. By following the example code, users can automate door opening and closing through IoT commands, enhancing security and convenience.
Hardware Preparation
- micro:bit board: Quantity 1
- Micro: IoT expansion board: Quantity 1
- Servo (S1): Quantity 1
- DFRobot Easy IoT platform access: Quantity 1
Software Preparation
- Makecode online graphical programming platform: https://makecode.microbit.org/
- Micro:IoT library: https://github.com/DFRobot/pxt-microIoT
- How to install an library?
Wiring Diagram
- Connect the servo to S1 of the Micro: IoT expansion board.
- Plug the micro:bit board into the Micro: IoT expansion board.
Other Preparation Work
- Open the Easy IoT website:http://iot.dfrobot.com.cn/
- Sign up/Sign in to Easy IoT.
- Add a new device to match your micro:bit, get the device topic.
Sample Code
Makecode programs: remote entrance guard system
Result
Press down button A, the telephone number will be displayed. If the house master gets the phone call, he will send command "ON" via Easy IoT to the guard system, the servo rotates to 90 degrees to open the door. 1 minute later, the servo rotates to 10 degrees, the door will be closed.
Was this article helpful?
