A2.1 Input from buttons, sensors and keyboards
A program can read input while it runs: a button press, a sensor reading, a typed value. The code names where the value comes from; the value itself arrives when the program runs. That lets one program respond to whatever happens.
Example
During this run the button has been pressed 4 times. Trace the program: what does each print show, and what if a sensor replaced the button?
- First print: 4 — the value read from the button this run.
- Second print: 15 — total was set to 10, then 5 was added.
Remember: A sensor source would print whatever the sensor read; the code stays the same.
A2.2 Coding, emerging technology and the trades
Example
Describe what a live wire tester and a hangar load app change for the people who use them.
- Tester: the electrician learns the wire is carrying current before touching it, instead of after.
- Load app: the loadmaster sees how cargo placed forward or aft changes the plane's balance before the door closes.
Example
Describe what a trail camera changes for the people who use it.
- Trail camera: the field biologist records animals that a single visit would miss. Each tool adds a reading; the judgement stays with the person.
Summary
- Input arrives at run time from a named source.
- Same code, different source, different values.
- Tools add readings; people keep the judgement.