Week 2 · Lesson 2 · 55 minutes
Program and trace your transitions
Build and explain this stage of your own connected prototype.
Planned lesson. Follow your teacher’s teaching order.
Task steps and checks
Do the work
- Save a copy and a short build plan with time, resources and checks. If needed, check each LED on its own first. Unplug USB before changing wiring; ask the teacher to check pin, polarity, ground and each LED’s own resistor.
- Implement and trace one valid event, one repeat and one invalid event. In the starter, command validates the input; ledOn reads the stored state to decide the output.
- Example: an invalid key should not change either light or make an old report look new. A repeated valid report may renew the report without restarting the flash.
- Serial command
- Validate
- Store state
- Set both lights
Check your result: Write your expected results first. Then compare your actual state and both LEDs for each event. A trace is not a hardware test. If you cannot run it, write NOT TESTED.
Revised weekly handout pages: 1, 2.
Materials
Existing October design, saved code, teacher-verified ESP32 circuit, USB data cable and computer; shared hardware, individual evidence.
Resources
Vocabulary
- State transition
- A rule linking the current state and an event to the next state and output.
Original classroom model
Trace state, age and flash phase
Match this trace to status_logic.h. Report age uses confirmedAt; flash phase uses changedAt. Both are timestamps, but repeated reports update only one. The browser connection is a later build step.
Use the buttons to step through. With scripts off, every frame remains readable.
New command at 1000 ms
- Command 2 valid
- State = 2
- changedAt = 1000
- confirmedAt = 1000
Busy starts a 500 ms cycle: LED B is on for the first 250 ms and off for the next 250 ms. LED A is off.
Read the diagram
- Command 2 valid
- State = 2
- changedAt = 1000
- confirmedAt = 1000
Repeat 2 at 1600 ms
- State = 2
- changedAt = 1000
- confirmedAt = 1600
- Phase = 100 ms
At 1600 ms, phase is (1600 − 1000) mod 500 = 100 ms, so LED B is on. The valid repeat resets report age to zero, not the flash phase.
Read the diagram
- State = 2
- changedAt = 1000
- confirmedAt = 1600
- Phase = 100 ms
Invalid X at 1700 ms
- X rejected
- State = 2
- Report age = 100
- Phase = 200 ms
No timestamp changes. Age is 1700 − 1600 = 100 ms. Phase is (1700 − 1000) mod 500 = 200 ms; LED B remains on.
Read the diagram
- X rejected
- State = 2
- Report age = 100
- Phase = 200 ms
Which values change for a repeated valid command, and which change for an invalid command?
Discuss before revealing
A repeated valid command refreshes confirmedAt without changing changedAt or state. An invalid command changes none of them. This keeps the flash phase running while refreshing the report.
See it
More examples and practice
Retrieve your saved version · 5 minutes
Open your own latest code and evidence. State what actually works and the next check; keep earlier versions.
Program and trace your transitions · 10 minutes
Separate input, decision and output. command validates an event before changing stored state; ledOn reads that state. Save a build plan with time, resources and checks before editing. Reference existing requirements and justify any changes.
Should an invalid command change the LED or refresh the report age?
Reveal reasoning
No. Reject it before changing either value. A repeated valid report may refresh its age without restarting the flash pattern; explain your own rule.
Build test and record · 30 minutes
Work through the task below. Take turns with hardware; each student records their own actions, predictions and observations.
Practice
- Implement your transition table in the supplied status logic. Trace a valid event, a repeated event and an invalid event. Repair or finish the physical indicator if needed; keep actual observations separate from predictions.
Save and explain your evidence · 10 minutes
Save the version and results. Explain one decision and one limitation to a partner. Record unfinished work for the next lesson instead of claiming success.
Choose the event that changes the state / Program and trace your transitions
Do only the parts you did not finish in class. Write what really happened; if you did not test something, write NOT TESTED. This is one task for the week, and nothing else is due.
- Open this week’s handout and your saved code.
- Finish the evidence for both lessons. Use only your saved code and real results.
You are finished when: The evidence for both lessons is complete and matches what you really did.
Why this matters: Each week’s evidence becomes part of the connected prototype evidence you submit in Week 8.
- There is no hardware task at home.
Revised weekly handout pages: 1, 2.
Weekly homework (Word) · Chinese weekly handout (Word)
Feedback on this week’s evidence
Task feedback only. Final C and D are separate best-fit judgements out of 8 using the school’s current MYP Year 5 criteria; do not average weekly bands.
- This week’s task
- Choose the event that changes the state / Program and trace your transitions
- Personal evidence and explanation
- Identify your own technical action, evidence file, actual outcome and limitation.
| Band | Observable evidence |
|---|---|
| 0 | No assessable evidence for this task yet. |
| 1–2 | Identifies parts of the task; personal work and results are difficult to follow. |
| 3–4 | Completes some steps with support; evidence or explanations have gaps. |
| 5–6 | Completes the task with traceable personal evidence and explains results and limitations. |
| 7–8 | Works independently, uses precise evidence to justify decisions and checks the effect of changes. |