Skip to content
All posts

Sensor lights, kettles that switch off, doors that open by themselves: finding the hidden programs around your home

A street lamp shining under a crescent moon, a traffic light with red, yellow and green lights, and an electric kettle on its base with steam rising from the spout.

The supermarket door slides open as you walk up to it. The kettle clicks off when the water boils. The light in the hallway comes on by itself when someone passes. To a child, it can look like magic. In fact, each of these machines is following a rule that a person wrote for it: a small program.

Finding these hidden programs is a gentle way into coding for children aged about 6 to 11. They don't need a computer, only sharp eyes and curiosity. This article gives you a hunt to do at home and in the street, a way to guess each rule, and a simple way to draw it as steps.

A hidden program is a "when… then…" rule

Most automatic machines work with a rule of the same shape:

When something happens, then the machine does something.

  • When someone comes close to the door, then the door opens.
  • When the water boils, then the kettle switches off.
  • When it gets dark, then the street lamp turns on.

The "when" part needs a way to notice what is happening. That is the job of a sensor: a small part that notices light, movement, heat, weight or water. You can describe sensors to your child as the machine's senses.

What the machine needs to notice A sensor that notices it Our sense that does the same job
Someone walking past A movement sensor Eyes
Day or night A light sensor Eyes
Hot or cold A temperature sensor Skin
How full a tank is A float that rises with the water Eyes, or touching the water

Go on a program hunt

Walk around the house, then down the street or through a shop, and look for things that do something by themselves. Take a notebook and fill in a table like this one:

Thing What does it notice? What does it do? Our guess at the rule
Fridge The door opening Turns on the light inside When the door opens, then the light comes on
Toilet cistern The water level Stops filling When the water is high enough, then the water stops
Hand dryer Hands underneath Blows warm air When there are hands under it, then it blows
Traffic light Time passing Changes color After a while, then the next color comes on

Some things your child might find: an automatic faucet, a fridge, a washing machine, an elevator, a night light, a sensor light on a porch, a coffee maker with a timer, a toaster that pops up. Not every machine has a sensor. A traffic light often just follows the clock, always in the same order, and some have a button for people waiting to cross. That is a program too.

Guess the rule by watching

A guess becomes better when you test it. Choose a few safe experiments:

  • The fridge light. Open the door very slowly. At what moment does the light come on? Can your child find the small button or switch that the door presses?
  • The automatic door. Walk towards a shop door very slowly. How close do you have to be before it opens? Does it open for a trolley, or only for people?
  • The sensor light. In a hallway or on a porch with a sensor light, stand completely still. Does the light go off after a while, even though you're still there?

Kitchen machines like the kettle, the oven and the toaster get hot: there, your child only watches while an adult uses them. And nobody pokes at plugs or sockets to see how something works.

Draw the program as steps

Once your child has guessed a rule, ask them to draw it as a chain of steps, the way a programmer would. A question box has two exits, yes and no:

  1. Wait.
  2. Is someone close to the door? If no, go back to step 1.
  3. If yes, open the door.
  4. Wait a few seconds.
  5. Is anyone still close? If yes, stay open and go back to step 4. If no, close the door and go back to step 1.

The arrows that go back are what make the machine run all day: the program repeats again and again. Older children can draw the washing machine, which runs a sequence of steps (fill with water, wash, rinse, spin) and then stops.

When the rule isn't good enough

Hidden programs are often very simple, and that is why they sometimes get things wrong. Talk about it with your child:

  • The sensor light goes off while someone is reading quietly in the hallway. Why? What rule would be better?
  • A small child or a cat walks up to the shop door. Does it open? What does the sensor actually notice?
  • The porch light comes on during a dark, stormy afternoon. What does that tell you about its rule?

Each time, your child can invent a better rule. That is exactly what programmers do: they test a program, see where it fails and improve it.

A machine that changes after each event, following its rule without anyone touching it, is also the idea behind "Flipping switches" puzzles in the Patterns topic in Dologi, where each rail switch flips after a train passes and children work out where the next train will go.

In short

  • Many machines around us follow a "when… then…" rule written by a person: a small hidden program.
  • Sensors are a machine's senses: they notice movement, light, heat or water so the rule knows when to act.
  • Go on a program hunt, guess each rule, test it safely by watching, and draw it as steps.
  • Find where a simple rule fails, and invent a better one together.

Read more: The human robot game: screen-free coding with "when… then…" rules