AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Break it into parts

Week 18 · Unit 8: Be an innovator · 3 lessons
1

Parts of a problem

Computing 4: Unit 8, pp. 104–122
GoalUse decomposition to split a micro:bit gadget into its parts before writing any steps.
New words
micro:bit · a small programmable board with 25 lights, two buttons and sensorsdecomposition · breaking a task into smaller partscomponent · one part of a bigger probleminput · what the board senses, such as a button press, a shake or a touch on the logo
Explanation

A micro:bit is a small programmable board with 25 lights, two buttons and sensors. Before we write a program for it, we use decomposition: we break the job into parts. For a flashing gadget the parts are the input that starts it, the picture it shows, how long the picture stays on, how long the screen stays blank and how many flashes there are. These parts are the components. A bag light for walking home must do two different things. Button A flashes a left arrow quickly. Button B flashes a stop sign slowly. Each behaviour has its own input and its own picture, so we will write two separate algorithms. Small parts are much easier to write and to check.

Worked examples
ComponentTurn leftStop
Input that starts itbutton Abutton B
Pictureleft arrowstop square
Time on0.5 seconds2 seconds
Time off (blank screen)0.5 seconds1 second
Flashes in all63
The two behaviours of the bag light, split into components. Each column will become one algorithm.
ABbutton A: left arrow
When button A is pressed, the board flashes this arrow. It points to the left, so people can see where the walker will turn.
ABbutton B: stop square
When button B is pressed, the board flashes a square made of the 16 lights round the edge. It means “I am stopping”.
Class activity

Decompose a gadget (with family): think of a gadget that flashes or beeps, such as a reminder that flashes when the plants need water or a toy that beeps when it is shaken. Write the components on a card: input, picture or light, time on, time off, how many times. Fill in the card. Give it to another person. Could they act out the gadget from your card alone?

Practice
1
A wake-up gadget works like this: when the logo is pressed, it shows a sun for 1 second, leaves the screen blank for 2 seconds, and does this 5 times in all. Fill in the components.
ComponentWake-up gadget
Input that starts it?
Picture?
Time on?
Time off (blank screen)?
Flashes in all?
2
Which component is missing from this description? “When button A is pressed, show a heart. Then leave the screen blank for 1 second. Do this 3 times.”
3
Why do we write two algorithms for the bag light and not one?
4
What do you write for the input if a gadget must start when the board is shaken? Draw the picture you would show for a gadget that shows a smile.
?????????????????????????ABdraw a smile