Unit B · Things that move, things that show
What we are making: a device that measures the temperature, decides whether it is too warm, says so on its screen, and sounds a buzzer if it is. Three parts, one machine, and a decision you make yourself.
Everything on this page you have already used. The new thing is that they are working together — sense, decide, act — which is the shape of every machine in this book and most of the ones outside it.
int tooWarm = 28; — that 28 is not a fact, it is somebody's opinion, and
today it becomes yours. Before you upload: read the room's temperature, write it down, pick
your trigger number, and write one sentence saying why. You will be asked to defend it.
tooWarm line.Set tooWarm to exactly the room's temperature and upload. The alarm goes on, off,
on, off, because the reading wobbles a tenth of a degree either side. That is chatter.
The fix is a gap: on above 28, but not off again until it drops below 27.
| What you see | Why | What to do |
|---|---|---|
| The buzzer never stops | Your threshold is below room temperature. | Read the screen, then set tooWarm above it. |
| The buzzer is barely audible | It is the passive buzzer. | Swap for the active one — the one with a sticker on top. |
| The alarm flickers on and off | The reading is sitting on your threshold. | That is chatter, not a fault. Leave a gap between on and off. |
TOO WARM stays up after it cools | OK is shorter. | Print trailing spaces so the longer word is wiped. |
In this session