Lite / Discovering How the World Works / Week 31
The rules inside your machine
A plant waterer that waters whenever there's water in the tank sounds fine, until you ask what happens when the soil is already wet.
Why should I care?
'Simple logical reasoning (a rule or flowchart)' is a capstone requirement. A flowchart is a conceptual prototype of your machine's brain: you can test it completely on paper, before any code or circuit exists.
- Write a machine's decision as an if-then rule and as a flowchart.
- Test a rule by checking every combination of inputs in a truth table.
- Find and fix a logic bug in a simple flowchart.
Predict
The rule is 'if the tank has water, open the valve'. The soil is wet and the tank is full. What does the machine do?
- Waits, because the soil is wet
- Opens the valve and waters anyway
- Lights the warning
Guess first, then reveal
The rule never asks about the soil, so it waters even when the pots don't need it. Over four days that floods the pots and empties the tank. The fix: water only if the tank has water AND the soil is dry.
Discover
Set the two sensors to each of the four combinations and trace the intended flowchart. Then switch to the buggy version and find the combination where it does the wrong thing. Use the truth table to check you've found every mismatch.
What the interactive shows (text version)
Flowchart as text: every 10 minutes, read the sensors. Question 1: is there water in the tank? If no, light the refill warning and wait. If yes, question 2: is the soil dry? If no, wait 10 minutes. If yes, open the valve for 10 seconds, then wait. The buggy version skips question 2, so it waters whenever the tank has water, including when the soil is already wet.
Understand
Rules as if-then
A machine's decisions can usually be written as if-then rules: if the tank is empty, then light the warning. If the tank has water and the soil is dry, then open the valve for 10 seconds. Write them in plain language first; they can become code or a circuit later.
Flowcharts
A flowchart draws the rules. Diamonds are yes/no questions. Rectangles are actions. Arrows show the order. Most machines loop: after acting, they wait and start again. Trace it with your finger for one situation at a time.
Test every combination
Two yes/no inputs give 2 × 2 = 4 combinations; three give 8. List them all in a truth table with what the machine should do and what your flowchart does. Any row where they differ is a bug. This tests your logic completely, for free.
Explain it another way
Intuitive
A flowchart is a choose-your-own-adventure book for the machine: each answer sends it to a different page.
Technical
The intended rule is water = tankOK AND dry, warn = NOT tankOK. The buggy rule is water = tankOK. They differ in exactly one row: soil wet, tank OK, where the bug waters and the intended rule waits.
Mathematical
With n yes/no inputs, a truth table has 2ⁿ rows: 2 inputs → 4 rows, 3 → 8, 4 → 16. Simple rules are easy to test completely; complicated ones quickly aren't.
Applied
The sorting-machine Build's level 2 asks for an 8-row rule table covering every combination of three sensor readings: a truth table in all but name.
Worked example 1
Write a rule for a night light that comes on when it's dark and someone is moving.
If dark AND movement, switch the lamp on for 2 minutes. Truth table: dark + moving → on; dark + still → off; light + moving → off; light + still → off.
Common mix-ups
If the rule works in the normal case, it works.
✓ Check every combination. Bugs hide in unusual cases.Flowcharts are only for programmers.
✓ Any machine that decides something has rules, and a flowchart shows them to anyone.
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
Write your capstone machine's rules as if-then sentences, draw them as a flowchart, and fill in a truth table for every combination of inputs. Mark any row where the flowchart does the wrong thing, and fix it. Add the flowchart, in words, to your Design Studio project.
Reflect
Which combination of inputs did you nearly forget to think about?
Write your answer on paper or in your own notes. Lite never stores what you write.