Lite / Discovering How the World Works / Week 20
Drawing algorithms as flowcharts
A greenhouse heater has no idea what a plant is. How can a simple drawing keep seedlings alive all night?
Why should I care?
Before engineers write code, they often draw it. A flowchart lets a whole team, including people who don't program, check an algorithm for mistakes. It is the most widely used design drawing in computing and control.
- Read a flowchart with start, step, decision and end shapes.
- Draw a flowchart for a short algorithm with one decision.
- Follow a flowchart for given inputs and say what happens.
Predict
A greenhouse controller repeats: measure the temperature, compare it with 18 °C, decide, act. Which step should come first?
- Act
- Decide
- Measure
Guess first, then reveal
Measure first. You can't compare or decide until you know the temperature. Putting steps in a flowchart forces you to notice what each one needs from the one before.
Discover
Match the greenhouse parts to their jobs, then put one turn of the control loop in order: measure, compare, decide, act. Sketch it as boxes and arrows as you go.
What the interactive shows (text version)
The greenhouse activity can be replaced by this description: the parts are a thermometer (measures temperature), a setpoint (the temperature we want, 18 °C), a controller (compares and decides), a heater (adds heat), a vent and glass (lose heat) and the cold night (pulls the temperature down). One turn of the loop is: measure the temperature, compare it with the setpoint, decide whether to heat, act by switching the heater, then measure again.
Understand
Four shapes
Most flowcharts need only four shapes:
- Rounded box: start or end.
- Rectangle: do a step ("turn heater on").
- Diamond: ask a yes/no question ("colder than 18 °C?"), with two arrows out.
- Arrows: show what comes next.
Decisions split the path
A diamond is where an algorithm becomes intelligent: the path depends on the answer. Every diamond must have both a Yes and a No arrow, or the machine doesn't know what to do half the time.
Arrows can loop back
An arrow that points back to an earlier box makes the steps repeat. A thermostat's flowchart loops back to 'measure' for ever. You'll study loops properly in week 23; for now, notice how easy they are to see in a drawing.
Explain it another way
Intuitive
A flowchart is like a board game path: you move along the arrows, and at some squares you must answer a question to know which way to go.
Technical
A flowchart is a directed graph: nodes are operations or decisions, edges are control flow. Each decision node has exactly two outgoing edges labelled true and false.
Applied
Hospital staff, pilots and factory workers all use flowcharts for emergencies ('Is the patient breathing? Yes → … No → …') because they are fast to follow under pressure and leave no gaps.
Worked example 1
Draw a flowchart for: 'If it is raining, take an umbrella. Then leave the house.'
Start → diamond 'Raining?' → Yes arrow to rectangle 'Take umbrella' → arrow to 'Leave house'; the No arrow from the diamond goes straight to 'Leave house' → End. Both branches meet again before the end.
Common mix-ups
Flowcharts are just for beginners.
✓ Professional engineers use them to design and check algorithms, especially for safety-critical systems.A decision only needs an arrow for the interesting answer.
✓ Every decision needs a path for both Yes and No.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Draw a flowchart for a smart bin that opens its lid when someone's hand is near, waits 5 seconds, then closes. Include at least one diamond and make the chart loop back so it works all day.
Reflect
Was it easier to spot mistakes in the drawing or in written sentences? Why?
Write your answer on paper or in your own notes. Lite never stores what you write.