メニュー
For this practice we are going to build a cardboard house with a door that opens automatically due to proximity.
When there is an object approaching, the door will open automatically and when there is no object it will close automatically.
ELECFREAKS BBC micro:bit V2.2
Wukong Expansion Board Adapter
Sonar:bit
ELECFREAKS 8 RGB Rainbow LED Ring
360° Servo
2 x Dupont Cables
Building blocks
Cardboard and double-sided tape
Note: Sonar:bit is the ultrasound module. The measurement range of the sonar:bit is 4cm-400cm. It can output stable and accurate measurement data with a tolerance of ±1cm only.
1. Download the cut-out house drawing and build the house with cardboard
2. Place the LEGO® or compatible pieces on the 360º servo and stick them to the door
3. The ultrasonic sensor is placed on the ceiling and the LED indicator near the door
1. To program it we need to add an extension. Click "Extensions" and search for "wukong" to download it.
2. Initialize the rainbow light first and set the pin to connect to P15
3. Set the ultrasonic pin to connect to P0, set the servo to 360° and connect it to S0.
If the ultrasonic detection distance is greater than 3cm and less than 15cm, the rainbow light will turn green, "yes" will be displayed and the servo will rotate 160°, pausing for 2000ms.If the ultrasonic detection distance is greater than 15cm, the rainbow light will go out, display no, the servo will rotate 240° and pause for 200ms.
4. You have the complete code solved at https://makecode.microbit.org/_bt1WHWMr5ipj
Sign up for our newsletter and be the first to know about coupons and special promotions.
© 2024, ELECFREAKS Powered by Shopify