Teach-Primary-Issue-19.8

Update a favourite, and help pupils learn coding skills with this micro:bit rock, paper, scissors project ADAM KN I GHT www.teachwire.net | 31 First, I recapped on a previous coding lesson we’d done, using the micro:bit’s light sensors to create a nightlight. If you have previously worked with this device, it would be worth recapping what the children remember, but if you haven’t, there are plenty of good intro videos online you can use to introduce the concept (such as this one on YouTube: tinyurl.com/tp-microbitIntro ). Explain that in this lesson, you’ll be using the micro:bit to play rock, paper, scissors. Children will now need something to trigger the random number generation. We decided to use the ‘when gesture’ and ‘shake’ blocks in Scratch to code the micro:bit to generate a number between one and three when it was shaken. Guide pupils to use the Scratch interface to drag the coding blocks into place, and trial shaking their micro:bits to generate a number. If some pupils are finding Scratch tricky, you could ask them to work in small groups, mixing abilities. Finally, set up a class tournament! Get groups or individuals to test out their codes to play rounds of rock, paper, scissors. You can tie this into maths learning on probability, and discuss real-world applications for the codes you’ve created. For example, can children think of ways people might use random number generators in the fields of gaming or cryptography? To tie into literacy skills, have children write a step-by-step guide to micro:bit rock, paper, scissors. Next, use the ‘if:randomnumber:equals’ blocks to program the LED display on the micro:bit to show either a rock, paper, or scissors icon when a corresponding random number is generated. We settled on one=rock; two=paper; and three=scissors, but any combination will do. Another trial-and-error session will allow pupils to test that their coding has worked, and if not, to look through and problem-solve to find any bugs. Load up Scratch on laptops ( scratch.mit.edu ) , and explain to the children that this is what you’ll be using to write your code. The first step is to create a variable. To be able to play an unbiased game of rock, paper, scissors, you’ll need your variable to be a random number between one and three (since there are only three possible choices when playing the game). Click on the ‘variables’ tool in Scratch, and support pupils to code a number generator. O ur Trust is very lucky in that we have amazing technology access, so for this lesson, children from across our seven schools were able to take part remotely, and I filmed my teaching from our state-of-the-art TV studio. It does not escape me that many schools don’t have this option, but this lesson will work perfectly well in-person in your classroom, as long as the children have access to micro:bits. Pupils will learn to code their micro:bits in order to play a game of rock, paper, scissors, and learn to use Scratch coding blocks to program random number generators and LED displays. F EATURE S COMPUT I NG AdamKnight is a Year 6 teacher at Westclyst Community Primary, part of Cornerstone Academy Trust. This lesson was also featured at MATPN SouthWest. For more MATPN events throughout the year, visit matpn-uk.com tcat.education

RkJQdWJsaXNoZXIy OTgwNDE2