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 1)

Week 29 Term 4 45-60 minutes

Learning Objective

Begin building your first complex, multi-component automated system. In Part 1, you will physically calibrate the Servo motor and draw a State Diagram — your blueprint for the logic before you write any rules.

Theory: Thinking in States

What is a State?

When building a complex automated system, it helps to think about what the system is currently doing. Each of these "modes" is called a State. A parking gate can be in one of two main states:

🚧

State: CLOSED

The gate arm is horizontal (e.g. Servo at 0°). No car is present. This is the default safe state.

State: OPEN

The gate arm is vertical (e.g. Servo at 90°). A car has been detected. The car can drive through.

What is a State Diagram?

A State Diagram is a map drawn on paper that shows:

  • All the States (circles) the system can be in.
  • The Transitions (arrows) that move the system from one state to another.
  • The Conditions written on each arrow — what sensor reading causes the transition?

Drawing a State Diagram before you write rules is the secret weapon of professional IoT engineers. It forces you to think through all the "what ifs" before you touch the keyboard.

🚧 CLOSED
↓   Distance (HC-SR04) < 10   →   Car detected!
OPEN
↓   Distance (HC-SR04) > 20 + Delay 3000 ms   →   Car has passed!
🚧 CLOSED

For Teachers

Have students draw the state diagram on paper using circles for States and arrows for Transitions. This bridges the flowcharting they learned in Week 20 with the multi-step Condition rules they will build next week. It also gives them a physical "spec sheet" to reference when programming.

Activity: Physical Calibration

Before writing any rules, we must make sure the hardware is set up correctly. A bad physical setup will break even the best code!

Step-by-Step Instructions:

  1. Connect and Assemble: Connect the SG90 servo and HC-SR04 to their matching labelled connectors on the MakerBuddy IoT Board. Then attach a small piece of cardboard or a popsicle stick to the Servo horn to act as the boom gate arm.
  2. Find the "Closed" Angle: Go to the Dashboard and manually adjust the Servo slider. Move it until the gate arm is perfectly horizontal (parallel to the ground). Write this angle down — e.g. .
  3. Find the "Open" Angle: Move the slider until the gate arm points straight up. Write this angle down — e.g. 90°.
  4. Calibrate the Distance Sensor: Point the HC-SR04 at the area where a car would stop. Place a book or toy car in front of it and read the Dashboard value. Then remove it and read again. Pick a threshold value between the two readings (e.g. if car = 8, no car = 35, threshold = 15).

📋 Write these down — you will need them next week!
Closed Angle: _____°  |  Open Angle: _____°  |  Car Threshold: _____

Challenge: The Paper Blueprint

Draw Your State Diagram

Use the State Diagram you saw above as a guide, and draw your own version with your actual calibrated values:

  • Draw two circles: label them "Gate Closed" and "Gate Open".
  • Draw an arrow from Closed → Open. Write the condition using your actual threshold (e.g. "Distance < 15").
  • Draw an arrow from Open → Closed. Write: "Distance > [bigger number] + wait 3000 ms".
  • Think: Why is the closing threshold a bigger number than the opening threshold? What happens if you use the same number for both?
Bonus: What would the state diagram look like if you also had a Yellow LED that turns on while the gate is open? Where would you add it?

Coming Up Next Week:

Week 30: Complex Automation: The Parking Gate (Part 2) — We bring the blueprint to life in the Rule Engine!