MB2: Shoot and Score
MAKECODE
Diagram
Code
Shooting the Ball: The code for shooting the ball requires 1 micro:bit. The radio channel can be set to any number so long as the number chosen when making the code for the Basket. On start the radio channel is set and the ball is displayed. When the micro:bit is shaken it will clear the screen and generate a random number between 1 and 3 which will be sent by radio to the micro:bit representing the basket. This number will be the score the player will receive for their throw.
Code available here
Scoring: The code for scoring requires 1 micro:bit. The radio channel must be the same as the channel chosen when shooting the ball. On start the radio channel is chosen and the basket is displayed. The radio is then set to receive any number and display the number it received. The random number generated when throwing the ball will be received by the basket and displayed, representing the score of that player's throw.
Code available here
Point Counter: The code for counting points requires one micro:bit with the code above. On start a variable called "points" is created which will store and display the counter. When A is pressed the counter will increase by 1. When B is pressed the counter will decrease by adding -1. When A+B are pressed it will reset the counter to 0. After each action the micro:bit will display the number of points.
Code available here
Game
Pass the ball and calculate maximum distance | 2 or more teams of at least 3 players | 3 micro:bits per team
Players will divide into teams made of atleast 3 members each. Each team requires 3 microbits. Two players from each team will stand at one end of the classroom with the micro:bits programmed with the code for Scoring and Point Counter to act as the basket and the scorer. The other players will line up one behind the other with the micro:bit with the code for Shooting the Ball. Players will take turns shooting the ball by shaking the micro:bit while the player at the basket will observe the score and the player with the Point Counter will tally the score. Once the ball is thrown the micro:bit is passed to the next player in line. To throw the ball again the micro:bit must be reset using the reset button on the back. Teams will compete for the highest score until each player has scored.
Note: if there are not enough micro:bits to have 3 per team, 2 micro:bits can be used per team and the score can be tallied using pen and paper or on the chalkboard..