GoalPlan, build on paper, test and evaluate a logic circuit for a sprinkler that waters only when the soil is dry and it is not raining.
New words
test plan · a table that lists the test data, the expected outcome, the actual outcome and pass or failexpected outcome · what the circuit should do, worked out before testingactual outcome · what the circuit really doesevaluate · to judge how well something works and how it could be better
Explanation
A project has four steps. First, plan: write what the inputs and the output are and work out the truth table by hand. Second, make: draw the logic circuit on paper. Third, test: use a test plan to compare the expected outcome with the actual outcome for every input pattern. Fourth, evaluate: say what works, what fails and how to improve it. Our problem is a sprinkler for a school garden. It should water only if the soil is dry and it is not raining. Adults handle all real water, pumps and electricity. We work only on paper.
Name
Meaning
Value 1
Value 0
D
soil dry?
dry
wet
R
raining?
raining
not raining
Z
sprinkler
on
off
Worked examples
D
R
NOT R
Z expected
1
0
1
1
1
1
0
0
0
0
1
0
0
1
0
0
Plan: the sprinkler must be ON only for dry soil with no rain. Rain means the plants do not need water, so rain must be turned round with a NOT gate. The plan is Z = D AND (NOT R). The expected outcomes are worked out first.
Test
Test data
Expected outcome
Actual outcome
Pass/fail
1
dry soil, no rain
sprinkler on
sprinkler off
fail
2
dry soil, rain
sprinkler off
sprinkler on
fail
3
wet soil, no rain
sprinkler off
sprinkler off
pass
4
wet soil, rain
sprinkler off
sprinkler off
pass
Test: a first design had only an AND gate between D and R, without the NOT gate. The test plan shows a mistake. In test 1 the soil is dry and there is no rain, so the sprinkler should be on, but the circuit keeps it off. In test 2 it waters in the rain.
Test
Test data
Expected outcome
Actual outcome
Pass/fail
1
dry soil, no rain
sprinkler on
sprinkler on
pass
2
dry soil, rain
sprinkler off
sprinkler off
pass
3
wet soil, no rain
sprinkler off
sprinkler off
pass
4
wet soil, rain
sprinkler off
sprinkler off
pass
Evaluate: adding the NOT gate fixes the circuit. After the fix, every test passes. But a good evaluation also asks other questions: does the soil sensor work in sunshine? Can the circuit say ‘not sure’ and call a person? How much water is used?
Class activity
Project day (no computer): choose another problem that needs two inputs, for example a reading-corner lamp that comes on if it is dark AND a child sits down, or a bike-shed light that stays off in daylight. Step 1: write the inputs and output with 1 and 0. Step 2: work out the truth table by hand. Step 3: draw the circuit as labelled boxes. Step 4: make a test plan with expected and actual outcomes and ask a partner to fill in the actual column by following your drawing. Step 5: write two sentences to evaluate it. Never use mains electricity or real water for this activity. If you have a computer or tablet, an adult can help you type the test plan.
Practice
1
Fish-tank light: it should come on only if the room is dark (D = 1) AND someone is near (N = 1). Complete the expected outcomes.
Test
D
N
Expected Z
1
0
0
?
2
0
1
?
3
1
0
?
4
1
1
?
D = 0, N = 0 gives off. D = 0, N = 1 gives off. D = 1, N = 0 gives off. D = 1, N = 1 gives on.
2
A plant lamp uses Z = NOT B, where B = 1 means the room is bright. The test plan has one fail. Which test fails, and what is wrong?
Test
B bright?
Expected
Actual
Pass/fail
1
1
lamp off
lamp off
pass
2
0
lamp on
lamp off
?
Test 2 fails. B = 0 (dark) should give a lamp on, but the actual outcome is off, so the NOT gate is missing or wired wrongly.
3
Write the expected outcome for the sprinkler when the soil is wet and it is raining. Explain why.
Sprinkler off. D = 0, so D AND (NOT R) = 0, and the plants do not need water anyway.
4
Write two evaluation sentences for the sprinkler circuit: one good point and one improvement.
For example: all four tests pass, so the logic is right. It could be improved by adding a light so the helper can see when it is on, or by checking the sensors.