Warning: Cannot modify header information - headers already sent by (output started at /var/www/wordpress_sites/aptanet_org-codeclub/wp-content/themes/blogus/inc/ansar/font/font.php:1) in /var/www/wordpress_sites/aptanet_org-codeclub/wp-includes/feed-rss2.php on line 8 Micro:bit – Morelands Code Club
https://codeclub.aptanet.org
Morelands Primary SchoolThu, 31 Jan 2019 14:41:58 +0000en-GB
hourly
1 https://wordpress.org/?v=6.9.1159665447Random Number Sender
https://codeclub.aptanet.org/2019/01/random-number-sender/
https://codeclub.aptanet.org/2019/01/random-number-sender/#respondThu, 31 Jan 2019 14:41:52 +0000http://codeclub.aptanet.org/?p=200Random Number Sender for the BBC Micro:bit
You will now have the code editor ready to use, so let’s get started. When we start we want to set a ‘radio group’ and show a tick so we know the Micro:bit is ready to go. In the ‘on start’ block add the blocks shown below:
Set Radio
Now we need a large block which does several things, and keeps doing them forever. You will put these blocks into the ‘forever’ block. This is what they do:
if button A is pressed (button A is the left one)
pick a random number between 0 and 9 and keep it safe in a variable
send the random number over the radio
show the number on the display (so we know what it was
pause for 2 seconds
set the display back to the tick so we are ready for the next one
Send Number
So each Micro:bit can receive the numbers as well as send we need a block for that. It uses an ‘on radio received’ block to show the number for 2 seconds and then wait for another.
Receive Number
Here are some things to try:
What happens if you change the number in the ‘radio set group’ block?
Can you send a message instead of a number?
]]>https://codeclub.aptanet.org/2019/01/random-number-sender/feed/0200Rock, Paper, Scissors for the Micro:bit
https://codeclub.aptanet.org/2018/02/rock-paper-scissors-microbit/
https://codeclub.aptanet.org/2018/02/rock-paper-scissors-microbit/#respondTue, 06 Feb 2018 14:42:10 +0000http://codeclub.aptanet.org/?p=119Rock, Paper, Scissors for the BBC Micro:bit
You will now have the code editor ready to use, so let’s set an image for the start of the game. Drag a show leds box across into the start block.
Start image
We are going to shake the Micro:bit to tell it to choose between Rock, Paper and Scissors, so find and on shake block. Inside that we need to set a variable to a random number between 0 and 2 (remember variables from our Scratch projects).
Random number on shake
Depending on which number was chosen we want to show a different image. A 0 is going to be a Rock, so we need an if-then-else block. Look in the logic section to find a way to compare the variable (item) with 0, and then draw a picture of a Rock in a show leds block.
Is it a Rock?
We are still left with two more options, Paper or Scissors, so we need to have another if-then-else block in the else part of the block we’ve just added. This time we will check to see if item is 1 and draw a picture of a piece of Paper.
Is it Paper?
There are only 3 options, so for our simple project we can assume that if it isn’t Rock or Paper then it must be Scissors (with bigger projects be careful about making assumptions!), so put a show leds block in with an image of some scissors.
It must be Scissors
To finish off we need to wait for a while to see which item has been chosen and then reset the image to the one we used at the start – why do you think that is a good idea?
Wait and reset
Once you’ve tested your project try clicking on the Javascript {} button at the top. This is the same project, but showing the Javascript code behind the blocks.