Year 9 · Summer 1
Physical Computing · Lesson 4 of 5
Designing a device for a user
TheoryTopic 13 Programming basicsTopic 11 Algorithms
Year 9 · Physical Computing · Lesson 4 of 5
You will learn to
- Identify who the user is, what problem they have, and what the device must never do.
- Plan the inputs, process and outputs of a device in a table.
- Write the device's decisions as plain steps or a flowchart before building.
- Create a parts list that says what each part is for.
Year 9 · Physical Computing · Lesson 4 of 5
Success criteria
You have got it when you can say:
- I can describe my user and their problem in two sentences.
- I can fill in an input, process, output table for my device.
- I can talk a partner through my plan, step by step, before I build.
Year 9 · Physical Computing · Lesson 4 of 5
Retrieval starter
Questions from before. Write your answers, then show them.
- Last lesson
A OR B, with A = 0 and B = 1, gives…
A 1B 0
A. 1
- Last unit
Double the width and the height. The file becomes…
A 2 times biggerB 4 times bigger
B. 4 times bigger
- Earlier this year
word = "Python". What is word[1:4]?
A "Pyth"B "yth"C "ytho"
B. "yth"
Year 9 · Physical Computing · Lesson 4 of 5
Key words (1 of 4)
- Variable
- A named place in memory that holds a value.
- Assignment
- Storing a value in a variable. = in Python, ← in pseudocode.
- Casting
- Changing a value from one data type to another, like int("13").
- Concatenation
- Joining strings together: "7" + "7" = "77".
Year 9 · Physical Computing · Lesson 4 of 5
Key words (2 of 4)
- Selection
- Choosing a path with if / else.
- Iteration
- Repeating steps: a loop.
- Boolean
- A value that is only True or False.
- Infinite loop
- A loop whose condition never becomes false.
Year 9 · Physical Computing · Lesson 4 of 5
Key words (3 of 4)
- Algorithm
- Precise, ordered, finite steps to solve a problem.
- Decomposition
- Breaking a problem into smaller ones.
- Abstraction
- Ignoring detail that doesn't matter for the problem.
- Sequence · selection · iteration
- Steps one after another. First this, then this.
Year 9 · Physical Computing · Lesson 4 of 5
Key words (4 of 4)
- Pseudocode
- Code-like writing for algorithms, without strict rules.
- Trace table
- Records variable values step by step to check logic.
The explanation · step 1 of 4 · part 1 of 2
Start with the user
A brief is a short description of a problem and who has it. Good devices start with the user, not the parts.
- Who will use it?
- What problem does it solve for them?
- Where will it be used?
- What must it never do?
The explanation · step 1 of 4 · part 2 of 2
Start with the user (continued)
Brief: a crossing outside the school. Users: pupils on foot, and drivers. It must never let cars go while people are crossing.
Think about every user. A person who cannot see well needs a sound as well as a light.
The explanation · step 2 of 4 · part 1 of 2
Inputs, process, outputs
A sensor is an input part that measures something, like light or temperature.
An actuator is an output part that acts on the world: a light, a buzzer or a motor.
| Part of the system | Crossing example |
|---|---|
| Input | A push button for people who want to cross |
| Process | The program decides when to change the lights |
| Output | Red, amber and green lights for the cars |
| Storage | A count of how many times people crossed |
The explanation · step 2 of 4 · part 2 of 2
Inputs, process, outputs (continued)
An embedded system is a computer with one job. Your device is one.
The explanation · step 3 of 4 · part 1 of 2
Plan the decisions on paper
Write the steps in plain words before any code. Add the time for each step.
start: green for cars
forever:
if the button is pressed:
amber for 2 seconds
red for 5 seconds (people cross)
red and amber for 1 second
green for carsYou can draw the same plan as a flowchart. The 'button pressed?' question is a diamond.
The explanation · step 3 of 4 · part 2 of 2
Plan the decisions on paper (continued)
Why plan on paper?
Changing a plan takes a minute. Changing wires and code can take a lesson. A plan also shows what to test later.
The explanation · step 4 of 4
The parts list
| Part | How many | Its job |
|---|---|---|
| Arduino Uno R3 | 1 | Runs the program |
| Breadboard Small | 1 | Holds the circuit together |
| LED: red, yellow, green | 3 | The traffic lights (yellow plays amber) |
| Resistor, 220 Ω | 3 | One for each LED, to limit the current |
| Pushbutton | 1 | The crossing button |
| Resistor, 10 kΩ | 1 | Pull-down: keeps the button pin at 0 until it is pressed |
Every LED needs its own resistor. Every button input needs a pull-down resistor.
Year 9 · Physical Computing · Lesson 4 of 5
Worked example (1 of 2)
Brief: a door alarm for a younger brother's bedroom. Plan it before you build.
- User: a child who wants to know if someone opens the door. It must never sound while the alarm is switched off.
- Inputs: a door sensor, and a slide switch to turn the alarm on or off. In Tinkercad, a pushbutton stands in for the door sensor: pressed means 'door open'.
- Process: if the alarm is on AND the door is open, sound the alarm.
- Outputs: a piezo buzzer (a tiny speaker) and a red LED.
Year 9 · Physical Computing · Lesson 4 of 5
Worked example (2 of 2)
Brief: a door alarm for a younger brother's bedroom. Plan it before you build.
- Parts: Arduino, breadboard, slide switch, pushbutton with a 10 kΩ pull-down, piezo buzzer, red LED with a 220 Ω resistor.
- Notice the process is an AND gate, just like last lesson.
Year 9 · Physical Computing · Lesson 4 of 5
Quick quiz · 1 of 3
Which shape is used for OUTPUT total?
- A Parallelogram
- B Diamond
- C Rectangle
A. Parallelogram
Input and output are always parallelograms.
Year 9 · Physical Computing · Lesson 4 of 5
Quick quiz · 2 of 3
What does print("3" + "4") show?
- A 7
- B 34
- C An error
B. 34
They're strings, so + joins them: 34.
Year 9 · Physical Computing · Lesson 4 of 5
Quick quiz · 3 of 3
What does 17 % 5 give?
- A 2
- B 3
- C 3.4
A. 2
17 ÷ 5 = 3 remainder 2. % gives the remainder.
Year 9 · Physical Computing · Lesson 4 of 5
Exit ticket
Answer on paper before you go. Then check.
range(3) gives…
A 0, 1, 2B 1, 2, 3C 0, 1, 2, 3
A. 0, 1, 2 Starts at 0, stops before 3.
x = input("Number: ") and the user types 5. What type is x?
A intB floatC str
C. str input() always gives a string: "5". Cast it with int() to do maths.