Skip to content

💻 Coding & Logic

If it's dry, water it: IF, AND, OR, NOT

Write the rules for a smart sprinkler, porch light and fan using IF, AND, OR and NOT, then test them against every situation. This is how smart devices decide.

⏱️ 25 min🎂 Ages 5–8, 9–12📈 medium
  • Computational thinking
  • Critical thinking
  • Problem solving

🧰 You will need

  • 1 × Piece of thin card (cereal box)
  • 1 × Pencils and crayons
  • 1 × Scissors

💡 How does a smart light know when to switch on?

A “smart” device isn’t really clever. It follows rules written by a programmer, like: IF it is dark AND someone is near the door, THEN switch the light on. Words like IF, AND, OR and NOT are how computers make decisions. They’re called logic.

🎮 Try it on the screen

Build a rule for each gadget. Then press Check my rule: it tests all 4 situations, and every row must be ✅, not just one.

IF the soil is dry it is raining THEN turn the water ON

Tap the grey and yellow boxes to change the rule.

Machine: turn the water ON ✅

Test every situation
the soil is dry?it is raining?Your ruleShould
nonooffoff✅
noyesONoff❌
yesnoONON✅
yesyesONoff❌

Some tests fail (❌). Change NOT, AND or OR until every row is ✅.

🛠️ Rule cards game

  1. Cut card into small cards. Write a situation on each: “raining”, “sunny”, “night”, “day”, “hungry”, “school day”, “weekend”.
  2. Write a rule on a big card, like: “IF sunny AND weekend, THEN go to the park”.
  3. Shuffle the situation cards and pick two. Does the rule say “go to the park”? Everyone shouts YES or NO!
  4. Change AND to OR. Play again. What changes?
  5. Add NOT: “IF NOT raining AND weekend”. Try every pair of cards.
  6. Now make up a rule for a real machine: an automatic door, a rice cooker, a phone alarm.

💡 What happened?

  • AND means both things must be true. It’s strict.
  • OR means at least one is true. It’s easy-going.
  • NOT flips true to false.

Good programmers don’t just try their rule once. They test every possible situation. With 2 inputs there are 4 situations; that list is called a truth table.

Did it work?