Input, output and physical systems
Computer Science · Key Stage 2 · The School
Two directions
INPUT is anything going into the program: a key press, a click, a microphone, a temperature sensor, a button on a robot. OUTPUT is anything coming out: text on a screen, a sound, a motor turning, a light. Every program sits between the two — take something in, decide, send something out. Naming which is which makes any system easier to think about.
Controlling something real
A program that controls a physical system does the same, but the output moves something. A traffic light changes colour on a timer; a buggy turns its motors; a greenhouse opens a vent. The program itself has not changed shape — what changed is that a mistake now has physical consequences, which is why such systems are tested in simulation first.
Sense, decide, act
Most control systems run one loop over and over: SENSE the input, DECIDE using a rule, ACT on the output, and repeat. A thermostat senses temperature, decides whether it is below the target, and acts by switching the heating. Writing a system as those three steps makes it clear where a fault must be — a wrong reading, a wrong rule, or a wrong action.
SENSE: a temperature sensor reports 31 °C. DECIDE: the program compares it with the target of 25 °C and finds it too warm. ACT: it sends a signal to a motor that opens a vent. The sensor did not decide anything and the motor did not either — all the judgement is in the middle. Change only the middle and the same hardware becomes a heater controller instead.