7. Case 07: The Basketball Counter#

7.1. Purpose#


To make a basketball counter.

../../_images/case-07-01.png

7.3. Materials Required#


../../_images/case-07-02.png

Video link: https://youtu.be/0P88GP4RQaw

7.4. Bricks build-up#


../../_images/step-case-07-01.png

../../_images/step-case-07-02.png

../../_images/step-case-07-03.png

../../_images/step-case-07-04.png

../../_images/step-case-07-05.png

../../_images/step-case-07-06.png

../../_images/step-case-07-07.png

../../_images/step-case-07-08.png

../../_images/step-case-07-09.png

../../_images/step-case-07-10.png

../../_images/step-case-07-11.png

../../_images/step-case-07-12.png

../../_images/step-case-07-13.png

../../_images/step-case-07-14.png

../../_images/step-case-07-15.png

../../_images/step-case-07-16.png

../../_images/step-case-07-17.png

7.5. Installation Mthods of Hardwares#

Install the sonar:bit with the bricks.

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

7.6. Hardware Connection#

Connect a sonar:bit to P1 port on Wukong breakout board.

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

7.7. Software Platform#


MakeCode

7.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-07-03.png

Link:https://makecode.microbit.org/_hueHXycJJgv1

Result#

When the ultrasonic sensor detects the ball goes through the basket, it will be counted, and the value will be displayed on the micro:bit. (The principle of ultrasonic counting in this case requires to be tested according to the actual construction of the basket, it is the detection of ultrasonic sensors to the ball basket with the fixed distance value, and by judging this fixed distance value, the score plus one, so as to achieve the purpose of counting. (Ultrasonic sensor counting may have deviations, inaccurate, belonging to the normal situation of not detecting the small ball.