# Case 04: Obstacles-avoidance Cars ## Purpose --- To make an obstacle-avoidance car. ![](./images/case-04-01.png) ## Link --- [micro:bit Wonder Building Kit](https://www.elecfreaks.com/micro-bit-wonder-building-kit-without-micro-bit-board.html) ## Materials Required --- ![](./images/case-04-02.png) Video link: [https://youtu.be/jYkSCfRpj1Y](https://youtu.be/jYkSCfRpj1Y) ## Bricks build-up --- ![](./images/step-case-04-01.png) ![](./images/step-case-04-02.png) ![](./images/step-case-04-03.png) ![](./images/step-case-04-04.png) ![](./images/step-case-04-05.png) ![](./images/step-case-04-06.png) ![](./images/step-case-04-07.png) ![](./images/step-case-04-08.png) ## Installation Mthods of Hardwares Install the sonar:bit with the bricks. ![](./images/Wonder-Building-Kit-step-sonar-bit-1.png) ## Hardware Connection Connect two [motors](https://www.elecfreaks.com/geekservo-motor-2kg-compatible-with-lego.html) to M1, M2, and the [sonar:bit](https://www.elecfreaks.com/sonar-bit-for-micro-bit-ultrasonic-sensor-distance-measuring-3v-5v.html) to P1 port on [Wukong breakout board](https://www.elecfreaks.com/wukong-board-with-lego-holder-for-micro-bit.html). ![](./images/Wonder-Building-Kit-case-04-06.png) ## Software Platform --- [MakeCode](https://makecode.microbit.org/) ## Coding --- ### Add extensions Click "Advanced" in the MakeCode to see more choices. ![](./images/case-01-03.png) Search with Wukong in the dialogue box to download it. ![](./images/case-01-04.png) Search with https://github.com/elecfreaks/pxt-sonarbit in the dialogue box to add the sonar:bit extension. ![](./images/case-04-04.png) ### Program ![](./images/case-04-05.png) Link:[https://makecode.microbit.org/_7K4bgpCKv2WJ](https://makecode.microbit.org/_7K4bgpCKv2WJ) ## Result While on start, the car moves forward at the full speed and it turns right if it detects any obstacles within the scope of 20cm, and then it keeps moving forward.