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

Logic gates and decisions

Week 25 · Unit 7.5: Living with AI · 3 lessons
3

Project: the garden sprinkler

Computing 7: Unit 7.5, pp. 150–181
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.

NameMeaningValue 1Value 0
Dsoil dry?drywet
Rraining?rainingnot raining
Zsprinkleronoff
Worked examples
DRNOT RZ expected
1011
1100
0010
0100
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.
TestTest dataExpected outcomeActual outcomePass/fail
1dry soil, no rainsprinkler onsprinkler offfail
2dry soil, rainsprinkler offsprinkler onfail
3wet soil, no rainsprinkler offsprinkler offpass
4wet soil, rainsprinkler offsprinkler offpass
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.
TestTest dataExpected outcomeActual outcomePass/fail
1dry soil, no rainsprinkler onsprinkler onpass
2dry soil, rainsprinkler offsprinkler offpass
3wet soil, no rainsprinkler offsprinkler offpass
4wet soil, rainsprinkler offsprinkler offpass
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.
TestDNExpected Z
100?
201?
310?
411?
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?
TestB bright?ExpectedActualPass/fail
11lamp offlamp offpass
20lamp onlamp off?
3
Write the expected outcome for the sprinkler when the soil is wet and it is raining. Explain why.
4
Write two evaluation sentences for the sprinkler circuit: one good point and one improvement.