How to play basketball with micro:bits • KCJ

How to play basketball with micro:bits • KCJ


Welcome coders! We’ll be releasing videos every month that show you fun ways to get hands-on with code. Let’s get started! Did you know that your micro:bit can also send messages through the air? That’s right! Your micro:bit has a radio function, and today we’re going to use it to make a simple basketball game. Here’s what you’ll need: Two micro:bits Two battery packs One friend Let’s head over to the MakeCode website to start putting our code together. Click here to access the platform! Start by clicking the new project button. Then delete the forever block by dragging it over to the block category list. Open the radio category and drag out the “Set Radio Group” block. Nest it in the “On Start Block” like this. We’re going to keep the number in the white circle set to 1. Now let’s go to the “Input” category and drag out “On Shake”. Place it anywhere in the coding area. Next, open the radio category again and drag out “Send Radio Number 0.” Nest it in the “On Shake” block. Let’s go back to the radio category and drag out “On Radio Received Number”. Go ahead and place it anywhere in your coding area. Under the Basic category, were going to drag out the”Show LED” block, and nest it under the “Radio Received Number” block Now it’s time to create your basketball using the LEDs on the micro:bit. The last block we need is “Clear Screen.” You can find it by clicking on “more” under the Basic category. Nest it under the “On Shake” block. Now our code is ready to go! Save is as radio one and download it on to the first micro:bit. Help your friend follow the same steps as you, but this time we’re going to add one more block to the code. Duplicate your basketball by right clicking the “Show LED” block. Nest it under the On Start Button. This extra block means your friend will start with the ball and pass to you when you start to play. Save this code as radio two and download it to the second micro:bit. Now it’s time for some hands-on fun! The hardware steps for this project are easy. All you have to do is plug in your battery packs. Now you’re ready to go! Give your micro:bit a shake! Did it pass the basketball to your friends’ micro:bit? If so, game on! If not, that’s ok. Rewatch the steps in this video to check your code and debug, then try again! Take turns shaking your micro:bits to keep passing the ball back and forth. Now that you’ve got the basics covered, can you take it to the next level? How far can you pass the ball? Across a room? Down the hall? Across a real basketball court? What about a bucket full of water? Grab a few more friends and see how many people you can add to your basketball team. What code do you need to build so more people can play? Have a good idea for our next video? Leave a comment below to let us know! Like this video and subscribe to our channel for more coding tips and tricks. See you soon!

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *