Programmable control: writing simple system logic

Design & Technology · Key Stage 3 · The School

Control as a written program

A programmable product's behaviour is decided by a written program, held in its microcontroller's memory, not fixed by the physical hardware alone. Changing what the product does, within the limits of its sensors and outputs, can mean changing only the program — no new physical parts required at all.

IF-THEN logic

Much simple control logic can be written as IF-THEN rules: IF a condition is true, THEN carry out an action. "IF the light level drops below a threshold, THEN turn the light on" describes an automatic light in one plain sentence, and that sentence is very close to the actual logic a programmer would write.

Combining conditions

Real control logic often combines more than one condition. "IF it is dark AND motion is detected, THEN turn the light on" behaves differently from either condition alone — the light does not come on for motion in daylight, and does not come on in darkness with nobody there. Combining conditions lets a designer build more specific, more useful behaviour than any single condition could produce.

An automatic garden light runs this logic: "IF light level is below 20% AND motion is detected within the last 10 seconds, THEN turn the light on for 60 seconds. ELSE turn the light off." At 2pm, light level reads 80% and motion is detected — the light stays OFF, because the light-level condition fails even though motion is present. At 10pm, light level reads 5% and no motion has been detected recently — the light stays OFF, because the motion condition fails even though it is genuinely dark. At 10:05pm, light level still reads 5% and motion is now detected — BOTH conditions are true, so the light turns ON for 60 seconds. Tracing exactly which conditions are true at each moment, rather than guessing at the light's behaviour, is exactly how a designer checks their own control logic actually does what they intended before it is built into a real product.

The School — all subjects · Knowledge map