SILO 3.4 (DRAFT)

Year 3, Term 4: Coding

Focus: Coding Scope and sequence: Coding

Learning intention: Students engage in coding to interact with virtual and tangible objects.

NSW Syllabus
Australian Curriculum (version 9.0)
"A student defines problems, describes and follows algorithms to develop solutions." (ST2-3DP-T)
"Students learn to implement simple algorithms as visual programs involving control structures and input." (AC9TDI4P04)


Introduction to the topic

This video (1:49) from NASA is an engaging look into the importance of coding.



Block-based coding

Introduction to block-based code using micro:bit (https://makecode.microbit.org/).

This video (2:09) is also a very good introduction to the BBC micro:bit.



The following picture identifies some of the components and features of the micro:bit.


(https://microbit.org/get-started/user-guide/overview/)

Using buttons on the micro:bit

The following screenshot depicts an introductory activity using the two buttons on the micro:bit.

You will notice that if using a mouse you can't press Buttons A and B simultaneously in simulation mode. This provides a good reason to load the code onto a micro:bit and then use the buttons on each device. Additional instructions for how to get the code onto the micro:bit are on the https://makecode.microbit.org/ site.

A logical next step for this lesson would be to ask the children to make their own version of this code where they have three different LED patterns. They could even make their own logos. If they can't think of anything you could suggest making a variation on the pattern listed above where they have diagonal lines for the 'A' and 'B' buttons. 'A' and 'B' together could then be programmed to make a multiplication symbol (x).

Making a simple game

This game uses randomly generated coordinates to light up an LED each time Button B is pressed. The aim is to illuminate all of the 25 LEDs as quickly as possible but the last ones are the hardest to get because the randomly generated coordinates will often be illuminating an LED which is already lit so it might appear that nothing is happening for a while.

Pressing Button A will clear the screen and restart the game. If other students have this game loaded on their micro:bits they can race each other by commencing the game at the same time.

Notes:

To make a potentially faster version of this game, modify the code so that each button will turn on an LED. The game will then allow you to use two thumbs or fingers instead of one. Also, modify the code so that the game is reset by pressing Buttons A and B at the same time. However, be careful not to press Buttons A and B accidentally during the game or the screen will be cleared and you will have to start again!

Are the any other ways to speed this game up? What if Button A was assigned for some of the LEDs and Button B was assigned for the others? How could you describe this scenario in terms of probability?

Making a thermometer

The micro:bit can detect the temperature so making a thermometer is as easy as using the following code. An alternative to this could be to use a blue 'Forever' block so that the temperature is continually displayed and updated rather than having to press a button.

Making dice

The micro:bit has an in-built accelerometer. This means that it can be used to detect motion, including being shaken. The following code is all that is required to make a dice.


Conditional statements

When it comes to making a decision or moving towards an end goal, it involves the process of checking and taking action. You are going through the action of checking if something is true or false, and then taking the corresponding action based on your findings. We call the combination of IF and THEN in the process of making a decision a CONDITIONAL STATEMENT, and this is very useful in the instructional aspect of coding.

Let’s go through some examples where we need to check the conditions before taking action. Try and point out which is the condition, which is the action.

IF it’s sunny out, THEN wear sunscreen.

In this one, the first step is to check the weather to see if it is sunny. If the statement that it’s sunny outside is TRUE, we will put on sunscreen. If it’s FALSE, we do not need to.


Activity
For today’s activity, everyone is going to get a number. Your task is to move through the classroom, stopping at each of the signs that have been put up around the room. These signs will consist of symbols we have learned so far in the unit (>, =, <). You are going to go through the conditional statement process we have outlined, first checking your number to see where it falls in relation to the symbol, then taking the action of moving to the correct side.

For example, if your number is a 6, and you come across a sign stating “< 9”, you are going to first check if this statement is true or not. Take a look at your number; if it is true that your number is < 9, move to the LEFT and check the next condition. Otherwise, move to the RIGHT. At the end of the game, we will see where each classmate ended up, and the path that they followed!

Coding a micro:bit for Rock Paper Scissors

Try making your own code so that you program the micro:bit to show either rock paper or scissors.


The following video (2:53) shows you how to code a micro:bit to play rock paper scissors.



A screenshot of the code is below using the same icons as the screenshot above. The other difference is that you can use Buttons A or B to clear the screen in between games.

Moderated self-assessment




Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Main menu