Students are able to understand the use of single choice control structure and variables in programming.
Students are able to produce a tortoise project that hides its head when the micro:bit is shaken at least 5 times.
A single-selection control structure is a system that has only one branch of a specified condition.
Sample of single-selection control structure.
Materials needed to follow this video:
micro: bit + USB wire + connector wire +3 alligator clips + 3V servo motor + power supply
Computer
Visit makecode.microbit.org
Plastic bottle + colored paper + cardboard
Transcript
Show the tortoise's head when the micro: bit is shaken at least 5 times.
Hide the tortoise head if shaken for 5 times and show the head if the turtle is shaken 7 times. Program micro:bit to reset the count when the button is pressed.
👉CLICK HERE👈 to try it on makecode.
Ways to build code.
End product.
A single selection control block in the “Logic” block drawer will be used. If the criteria are not met, no program will be executed.
Criteria can be set using comparison blocks.
Think about the last example:
To make the program work, the micro:bit has to remember the count and decide to hide the tortoise's head if it needs to. Event-based blocks can’t do everything. Single-selection control blocks help with this!
The comparison block is inside the "forever" block because we want the micro:bit to keep checking if the conditions are met all the time.
Test whether it is true or false.
Challenge 1
Draw a flow chart for the challenge in the video.
Challenge 2
Program micro:bit based on the flow chart below: