Level 3Unit C · Session 20
20

Unit C · A page somebody else can use

When something is wrong

What we are making: a page that changes colour when it needs attention, and an honest answer to the question ‘what if nobody is looking?’

Attention is the point

Everything you have built so far assumes somebody is looking at the page. Most of the time nobody is. So the device has to be able to say ‘look at me’ in a way that works from across a room.

Colour does this better than words. A red screen is readable at a distance where text is not, and it needs no language at all.

Session 20 — a page that shouts when it needs to — 3 slots
SLOT 2
your line, chosen after measuring
float tooWarm = 28.0; // your number
SLOT 3
the reading, and the verdict with it
float t = sensor.readTemperature();
String word = (t > tooWarm) ? "TOO WARM" : "All fine";
return String(t, 1) + " C - " + word;
SLOT 8
red when it is wrong, calm when it is not
float t = sensor.readTemperature();
if (t > tooWarm) return "#B3451F"; // alarm red
return "#1F7A6F"; // calm green
New words
Alert stateWhen the device has decided something needs a person.
HysteresisLeaving a gap between switching on and switching off again.
False alarmCrying wolf. The fastest way to get an alarm ignored.

Do it

  1. Add the colour logic to your page. Use your own threshold.
  2. Trigger it by warming the sensor, and look at the page from across the room.
  3. Set the threshold to exactly the room temperature and watch it flicker.
  4. Fix the flicker: go red above your number, but do not go back to green until it drops a degree below it.
  5. Add a buzzer on GPIO 25 that sounds only while the page is red, if you have time.

The honest question

Your alarm only exists while somebody has the page open. If nobody looks all night, nothing happened as far as your device is concerned.

That is a real limitation, and the right response is to say so rather than pretend otherwise. Write one sentence in your notebook: what my device cannot do. You will be asked this at the exhibition, and ‘nothing’ is the wrong answer.

💡 Tip
A false alarm costs more than a missed one, the second time. An alarm that goes off for no reason gets ignored, and then it is worse than no alarm at all. This is why the flicker in step 3 matters — it is not cosmetic.
What you seeWhyWhat to do
It flickers between red and greenThe reading sits on your threshold.Use two numbers: one to go red, a lower one to go green again.
The colour never changesThreshold beyond anything real.Print the reading and check it against your number.
Red is unreadableDark red text on dark red background.Keep the text white and change only the background.
The buzzer never stopsNothing turns it off.Set it LOW in the else branch, not just HIGH in the if.

What you learned

  • Colour carries further than words and needs no reading.
  • A gap between on and off stops an alarm chattering.
  • Knowing what your device cannot do is part of having built it.
Challenge optional — only if you finish early
  • Make the alarm remember how many times it has gone off since the board started.
19. Controls a stranger understands