Skip to content
MakerBuddy

Term 4 · Weeks 25–32

Creating smart automated systems with complex rules, capstone projects and a final expo. Each lesson includes its full classroom material, activity and challenge.

Complex Automation: The Parking Gate (Part 2)

Week 30 Term 4 45-60 minutes

Learning Objective

Translate your state diagram from last week into real Rule Engine rules! Use multi-step Condition rules with exact action names and ms delays to safely open and close the parking gate.

Theory: Multi-Step Rules & Jitter

Doing More Than One Thing

Until now, each of our rules only did one thing — like turning on a single LED. But a real parking gate needs to do several things in order when a car arrives:

  • Turn the RGB Green on (signal "Go!").
  • Move the Servo to the Open angle.

The Rule Engine lets you add multiple Steps to a single rule. Each step has its own Action and Delay (in ms). The steps run one after the other — in the exact order you set them.

Adding multiple steps

Adding Steps

Click the "+" button inside a rule to add more steps. Each step runs after the previous one finishes.

Configuring action steps

Configuring Each Step

For each step, choose the Action (e.g. Servo, RGB Green) and set the Delay in ms before the next step runs.

The Danger of Jitter — Solved with a Gap

Recall from Week 27: if the opening condition (Distance < 10) and the closing condition (Distance > 10) used the same threshold, the gate would rapidly open and close as the car sits right at the sensor edge. This is Jitter.

We fix this with a Threshold Window gap: open at < 10, but close only at > 20. A step’s delay happens after its action, so we place a 3000 ms delay on the open-indicator step before the closing-servo step.

Activity: Coding the Smart Barrier

Get out the numbers you wrote down last week (Closed Angle, Open Angle, Distance Threshold). Let's build both rules!

Rule 1 — Car Arrives ("CarArrived")

Condition mode | Sensor: Distance (HC-SR04) | Operator: < | Threshold: your value

Step 1:   Action → RGB Green   |   Delay: 100 ms
Step 2:   Action → Servo, Value → [Your Open Angle]°   |   Delay: 100 ms

Rule 2 — Car Leaves ("CarLeft")

Condition mode | Sensor: Distance (HC-SR04) | Operator: > | Threshold: a bigger number

Step 2:   Action → Servo, Value → [Your Closed Angle]°   |   Delay: 100 ms
Step 3:   Action → RGB Off   |   Delay: 100 ms
  1. Build Rule 1 as shown above. Save it.
  2. Build Rule 2 as shown above. Save it.
  3. Test it: Hold an object near the Distance sensor. The gate should open and the LED should go green. Pull the object away. After 3000 ms, the gate should safely close!

Challenge: The Broken Gate

Debugging Simulation

You are the lead engineer. A customer calls and says: "The gate opens fine, but as soon as the front of my car passes the sensor, the gate slams down on my roof!"

  • Which part of Rule 2 protects the car from being hit?
  • What would happen if the Delay in Step 1 of Rule 2 was 100 ms instead of 3000 ms?
  • What would happen if the closing threshold was > 10 instead of > 20?
  • Task: Write a 2–3 sentence explanation to the customer explaining how the Delay and Threshold Window work together to keep their car safe.

Coming Up Next Week:

Week 31: Capstone Project Design & Troubleshooting