Skip to content
MakerBuddy

Week 29 · Term 4 · 45 to 60 minutes

Complex Automation: The Parking Gate (Part 1)

Interfacing and State Diagrams

Try it first, no kit needed

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?

Think about what a system is doing right now: that mode is called its State. A parking gate has two main states:

🚧

State: CLOSED

The gate arm is flat (e.g. Servo at 0°). No car is there. This is the safe default.

✅

State: OPEN

The gate arm points up (e.g. Servo at 90°). A car is detected and can drive through.

What is a State Diagram?

A State Diagram is a paper map. It shows:

  • The States (circles) the system can be in.
  • The Transitions (arrows) that move it from one state to another.
  • The Conditions on each arrow: which sensor reading causes the move?

Engineers draw it before writing rules, to think through every what-if first.

🚧 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 diagram on paper: circles for States, arrows for Transitions. It links the Week 20 flowcharts to the multi-step Condition rules they build next week.

Try It: Calibrate the Gate and Draw Its States

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: Physical Calibration

Set up the hardware first. A bad setup breaks even the best code.

Step-by-Step Instructions:

  1. Connect and Assemble: With the USB cable unplugged, plug the SG90 servo into the 3-pin connector marked 19, and the HC-SR04 into the header marked HC-SR04 with its kit cable. Plug the USB back in; the board turns the servo to 0°. Press cardboard or a lolly stick onto the servo horn (the small arm on top) as the gate arm.
  2. Find the "Closed" Angle: On the 📊 Dashboard, drag the Position (0° - 180°) slider on the Servo Motor card until the arm is level with the ground. Write the angle down, e.g. 0°. (If the card says “This control is used by Rule Engine…”, stop or delete any rule that uses 🔄 Servo Move and set Potentiometer Mapping to None.)
  3. Find the "Open" Angle: Move the slider until the arm points straight up. Write it down, e.g. 90°.
  4. Calibrate the Distance Sensor: Point the HC-SR04 where a car would stop. Put a box or wall about 30–40 cm behind the parking spot, so the sensor always has something to measure. Put a book or toy car in the spot, wait 3 seconds and read the Distance card. Remove it, wait 3 seconds and read again. Pick a threshold between the two readings (e.g. if car = 8, no car = 35, threshold = 15).

📋 Write these down. You need them next week!
Closed Angle: _____°  |  Open Angle: _____°  |  Car Threshold: _____

Challenge: The Paper Blueprint

Draw Your State Diagram

Draw your own diagram with your real values:

  • Draw two circles labeled Gate Closed and Gate Open.
  • Draw an arrow from Closed → Open. Write the condition with your threshold (e.g. Distance < 15).
  • Draw an arrow from Open → Closed. Write: Distance > [bigger number] + wait 3000 ms.
  • Think: Why is the closing number bigger than the opening one? What if both were the same?
Bonus: Imagine you also had a Yellow LED that is on while the gate is open. Where would it go on your diagram?

Coming Up Next Week:

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

Learning Support

Use this quick guide to help every learner understand, practice and explain Complex Automation: The Parking Gate (Part 1).

For students

Try it in three steps

  1. Say it: explain the main idea in one simple sentence.
  2. Show it: Calibrate servo positions for the barrier arm. Map out state transitions.
  3. Stretch it: Draw your two-state diagram (Gate Closed, Gate Open) with your measured distances and the 3-second wait. Bonus: add a Closing state.

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.

Safety reminder: Plug the servo and the distance sensor in only while the USB cable is unplugged. Keep fingers clear of the gate arm while it moves, and turn it with the slider, never by hand.

Did you get it?

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

  1. 1What is a "state" in a state diagram?

  2. 2What do the arrows on a state diagram show?

  3. 3Why calibrate the car threshold using two readings, with and without a car?