4. Case 04: Obstacles-avoidance Cars#

4.1. Purpose#


To make an obstacle-avoidance car.

../../_images/case-04-01.png

4.3. Materials Required#


../../_images/case-04-02.png

Video link: https://youtu.be/jYkSCfRpj1Y

4.4. 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

4.5. Installation Mthods of Hardwares#

Install the sonar:bit with the bricks.

../../_images/Wonder-Building-Kit-step-sonar-bit-1.png

4.6. Hardware Connection#

Connect two motors to M1, M2, and the sonar:bit to P1 port on Wukong breakout board.

../../_images/Wonder-Building-Kit-case-04-06.png

4.7. Software Platform#


MakeCode

4.8. 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

4.9. 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.