Skip to content
MakerBuddy

Week 21 · Term 3 · 45 to 60 minutes

The Rule Engine & The 4 Loop Modes

How and when a rule runs

Try it first, no kit needed

The Rule Engine & The 4 Loop Modes

Week 21 Term 3 45-60 minutes

Learning Objective

Meet the MakerBuddy Rule Engine. Learn what every rule is made of, and understand the 4 Loop Modes that decide when and how often a rule runs.

Theory: The Brain of MakerBuddy

Until now, you were the brain. You pressed buttons and dragged sliders to tell the MakerBuddy what to do. The Rule Engine lets the MakerBuddy think for itself.

Here your Week 20 IF-THEN flowcharts become rules saved on the board. The board follows them by itself, even with the dashboard closed or your laptop off, as long as the board itself stays powered (for example from a USB phone charger).

Rule Engine Interface Overview

The Rule Engine tab: each row of the Rule Engine table is one saved rule. Several rules can run at the same time.

Every Rule Has Two Parts

Every rule, simple or complicated, answers two questions:

1. Loop Mode — when?

Tells the MakerBuddy when and how often to run the rule. Once? Non-stop? Every 5 minutes? When a sensor says so?

That is this week's lesson.

2. Steps — what?

Tells the MakerBuddy what to do when the rule runs. A rule holds up to 10 steps, run one after the other.

That is next week's lesson.

Engine limits: the MakerBuddy stores up to 10 rules, each with up to 10 steps. Rules are saved on the board, so they survive a power cut and restart with the device.

The 4 Loop Modes

The Loop Mode answers "How often should this rule run?" Pick one of the four with the radio buttons at the top of the rule form.

⏹️

No Loop (Run once)

What it does: Runs the whole sequence one time, then stops. It runs when you save it, when you press ▶️ Start, and again every time the board powers on.


Analogy: A water balloon in a slingshot. It fires once, then you reload it yourself.


✅ Use when: You want a one-time command.

Good examples:
  • Set the RGB color on startup
  • Move a servo to its home position
  • Send one "I'm awake!" beep on power-on
♾️

Forever (Continuous)

What it does: Runs the sequence, and as soon as the last step's Delay has finished it jumps straight back to step 1, with no extra pause.


Analogy: A heartbeat. Beat, beat, beat, forever, without waiting to be told.


✅ Use when: You need to lock an output in a state, or repeat a pattern without end, like a siren or a color animation.

⚠️ Important:

While a Forever rule runs, it overrides the dashboard controls for its output. Press ⏹️ Stop or 🗑️ Delete on the rule's row to take control back.

⏱️

Timer (Interval)

What it does: Runs the complete sequence straight away. When it finishes, it waits for your chosen interval, then runs again. You set the interval in hours, minutes and seconds. The rule list shows it as 🔄 Interval, for example "Every 5m 0s".


Analogy: A garden sprinkler. It sprays each morning, then waits until tomorrow.


✅ Use when: Something must happen on a schedule.

Good examples:
  • Flash a hazard light every 30 seconds
  • Water a plant every hour
  • Show sensor data on the LCD every 5 minutes
🎯

Condition (Sensor-based)

What it does: Watches one sensor condition, or two joined with AND/OR. While the result is true, it repeats the sequence. When it turns false, the rule finishes the current cycle and stops, leaving every output the way its last step set it. To switch an output (like a fan) off again you need an Off step, or a second rule (Week 26).


Analogy: A smoke alarm. It waits quietly, then the moment it senses smoke: BEEP BEEP BEEP!


✅ Use when: The MakerBuddy should react to a measurement: "If temperature is above 30°C, turn the fan on."

Good examples:
  • Turn a nightlight on when the room gets dark
  • Sound an alarm if gas levels are too high
  • Open a gate when a car is detected nearby

Quick Reference: Which Loop Should I Pick?

Ask yourself…AnswerMode to use
Should this happen only once?Yes, one time only.⏹️ No Loop
Should this repeat with no break at all?Yes, never stop!♾️ Forever
Should this repeat on a schedule, with gaps?Yes, every few seconds, minutes or hours.⏱️ Timer
Should this react to a sensor reading?Yes, react to the real world.🎯 Condition

Who Wins? Rule Priority

What if two rules try to control the same part at once? The Rule Engine settles it with a fixed priority order:

🎯 Condition  >  ⏱️ Timer  >  ♾️ Forever  >  ⏹️ No Loop

The higher-priority rule takes over the part it is using right now. Lower-priority rules can't touch that part until it is released. But two rules of the same priority fight over the output, and the result is unpredictable. Avoid this design mistake; you will see it happen in Week 23.

For Teachers

The four Loop Modes match a single call, a while(true) loop, a scheduled task and an event-driven trigger in any language. Rule priority works like interrupt priority in embedded systems.

Try It: Watch the Four Loop Modes

Interactive demo · no kit needed

Play with a pretend MakerBuddy board and its web page, right here.

Follow the steps one at a time. Got the kit? You can switch to the real board inside.

Activity: Tour the Rule Engine

This week you explore the screen. You build your first working rule next week.

Step-by-Step Instructions:

  1. Open the dashboard and go to the Rule Engine tab.
  2. Find the Loop Mode selector. It is the row of four boxes: No Loop, Forever, Timer and Condition.
  3. Click each mode in turn and watch the form change below:
    • No Loop and Forever show no extra settings.
    • Timer shows three boxes: Hours, Minutes and Seconds.
    • Condition shows the 🎯 Loop Condition box: a Sensor list, an Operator list and a Threshold box, plus Use Range and Add a second sensor (for Week 27).
  4. Open the Condition sensor list and write down all 10 sensors.
  5. Do not save anything yet. Just explore and tell a partner what you see.

Observation task: The form changes with the mode. Why does Timer need extra settings but Forever does not?

Challenge: Guess the Loop Mode

Which Mode Would You Use?

Pick the best Loop Mode for each scenario. Be ready to explain why the other three are wrong, then discuss your answers with the class.

  1. A factory siren that must blast non-stop for as long as the emergency is active.
  2. A reminder that beeps once every 20 minutes to tell a student to drink water.
  3. A streetlight that turns on when it gets dark and turns off when it gets bright again.
  4. A "System Online" green LED that lights up once when the MakerBuddy first boots up.
  5. A greenhouse water pump (the relay) that must switch on whenever the soil gets too dry.
Bonus: Can you spot a real device in your classroom for each of the 4 loop modes?

Key Takeaways

✓ A rule = Loop Mode + Steps

The Loop Mode answers when; the Steps answer what.

✓ Four ways to trigger

Once (No Loop), non-stop (Forever), on a schedule (Timer), or on a sensor reading (Condition).

✓ Rules live on the board

Up to 10 rules are saved on the MakerBuddy and keep running with the dashboard closed.

✓ Priority settles conflicts

Condition beats Timer beats Forever beats No Loop. Rules of the same priority still clash.

Coming Up Next Week:

Week 22: "No Loop" Mode & Multi-Step Sequences: build your first real rule, and make one rule control several outputs in order.

Learning Support

Use this quick guide to help every learner understand, practice and explain The Rule Engine & The 4 Loop Modes.

For students

Try it in three steps

  1. Say it: explain the main idea in one simple sentence.
  2. Show it: Tour the Rule Engine tab. Switch between the four modes and observe how the form changes.
  3. Stretch it: Guess the Loop Mode: pick the correct mode for five real-world scenarios and justify each choice.

Checkpoint: What was your input, what decision or process happened, and what was the output?

For teachers & parents

Coach without taking over

  • Before: ask the learner to predict what will happen and why.
  • During: use prompts such as “What changed?” and “What could you test next?” instead of giving the answer.
  • After: ask for a 30-second explanation, one piece of evidence and one improvement.

Look for: safe handling, correct vocabulary, a result the learner can demonstrate, and an explanation in their own words.

Did you get it?

Three quick questions. Pick an answer to see whether it is right, and why.

  1. 1Every rule answers two questions. What does the Loop Mode answer?

  2. 2Which Loop Mode fits "beep once every 20 minutes"?

  3. 3What happens when two rules try to control the same part at once?