Microbit Project: Basketball score counter

1 47196 Easy
*Created by Mark Ng
1 IR sensor
1 micro:bit
1 micro:mate(breakout board)
1 Gravity: Digital Speaker Module
1 Dupont cables
1 Basketball hoop
2 M4 20mm screws with nuts for mounting micro:bit


How does it work?


Distance adjustment 


decreases distance

 **Clockwise increases distance 


 When this IR detects an obstacle within range it will send an output low. 

Move your hand towards the IR LEDs. As you move near them, the IR receiver detects blockage and the obstacle LED will be lighted up.

 We are making a basketball score counter. When the loop detects a ball passing through, one count will be added to the score and a melody will be played. 

If you want to reset the score, press button A





IR sensor Micro: mate 

GND Pin 1 Black 

VCC Pin 8 Red(5V) 

OUT Pin 1 Blue 


Digital Speaker 

Black Pin 0 Black 

Red Pin 0 Red 

Green Pin 0 Blue


1. I used scraped acrylic and secured it using 2 screws and nuts and drilled 2 5mm holes.

2. Adjust the distance and test the range. Bend the ir at 90 degrees.

3. Slot the IR into the 2 holes (side view).

4. The back view of the IR sensor.


The M4 screws are used to replace the existing screws used in the micro: mate. As the screws are longer, we can mount the micro: bit and micro: mate onto the board.

The code


Even though the specifications state that it can operate from 3v to 5v, you will find that the 3v from the micro: bit will not be able to drive this IR sensor.

After programming, remember to connect the micro USB connector to Vin of the micro: mate and switch the selector switch to 5V.


All Rights