# Case 27: The Smart Garbage Can ## Purpose --- Make a smart garbage can. ![](./images/Wonder-Building-Kit-case-27-01.png) ## Link: --- [micro:bit Wonder Building Kit](https://shop.elecfreaks.com/products/elecfreaks-micro-bit-32-in-1-wonder-building-kit-without-micro-bit-board?_pos=5&_sid=2094afd2f&_ss=r) ## Materials Required --- ![](./images/Wonder-Building-Kit-step-case-27-01.png) ## Bricks build-up --- ![](./images/Wonder-Building-Kit-step-case-27-02.png) ![](./images/Wonder-Building-Kit-step-case-27-03.png) ![](./images/Wonder-Building-Kit-step-case-27-04.png) ![](./images/Wonder-Building-Kit-step-case-27-05.png) ![](./images/Wonder-Building-Kit-step-case-27-06.png) ![](./images/Wonder-Building-Kit-step-case-27-07.png) ![](./images/Wonder-Building-Kit-step-case-27-08.png) ![](./images/Wonder-Building-Kit-step-case-27-09.png) ![](./images/Wonder-Building-Kit-step-case-27-10.png) ![](./images/Wonder-Building-Kit-step-case-27-11.png) ![](./images/Wonder-Building-Kit-step-case-27-12.png) ![](./images/Wonder-Building-Kit-step-case-27-13.png) ![](./images/Wonder-Building-Kit-step-case-27-14.png) ![](./images/Wonder-Building-Kit-step-case-27-15.png) ![](./images/Wonder-Building-Kit-step-case-27-16.png) ![](./images/Wonder-Building-Kit-step-case-27-17.png) ![](./images/Wonder-Building-Kit-step-case-27-18.png) ![](./images/Wonder-Building-Kit-step-case-27-19.png) ![](./images/Wonder-Building-Kit-step-case-27-20.png) ![](./images/Wonder-Building-Kit-step-case-27-21.png) ![](./images/Wonder-Building-Kit-step-case-27-22.png) ![](./images/Wonder-Building-Kit-step-case-27-23.png) ![](./images/Wonder-Building-Kit-step-case-27-24.png) ![](./images/Wonder-Building-Kit-step-case-27-25.png) ![](./images/Wonder-Building-Kit-step-case-27-26.png) ![](./images/Wonder-Building-Kit-step-case-27-27.png) ![](./images/Wonder-Building-Kit-step-case-27-28.png) ![](./images/Wonder-Building-Kit-step-case-27-29.png) ![](./images/Wonder-Building-Kit-step-case-27-30.png) ![](./images/Wonder-Building-Kit-step-case-27-31.png) ## Installation Mthods of Hardwares Install the sonar:bit with the bricks. ![](./images/Wonder-Building-Kit-step-sonar-bit-6.png) ## Hardware Connection Connect a [servo](https://www.elecfreaks.com/geekservo-2kg-360-degrees-compatible-with-lego.html) to S0 and a [sonar:bit](https://www.elecfreaks.com/sonar-bit-for-micro-bit-ultrasonic-sensor-distance-measuring-3v-5v.html) to P0 port on [Wukong breakout board](https://www.elecfreaks.com/wukong-board-with-lego-holder-for-micro-bit.html). ![](./images/Wonder-Building-Kit-case-27-06.png) ## Software Platform --- [MakeCode](https://makecode.microbit.org/) ## Coding --- ### Add extensions Click "Advanced" in the MakeCode to see more choices. ![](./images/Wonder-Building-Kit-case-21-02.png) Search with Wukong in the dialogue box to download it. ![](./images/Wonder-Building-Kit-case-21-03.png) Search with IOT:bit in the dialogue box to download it. ![](./images/Wonder-Building-Kit-case-27-04.png) ### Program ![](./images/Wonder-Building-Kit-case-27-05.png) Link:[https://makecode.microbit.org/_XeMXzj7z3JFx](https://makecode.microbit.org/_XeMXzj7z3JFx) ### Result When the micro:bit is powering on, it displays a heart icon, then the lid will automatically open when the ultrasonic sensor detects someone approaching, and it will automatically close after three seconds.