Week 3 · Lesson 2 · 55 minutes
Program the three response regions
I can use readings to choose a useful alert limit.
Planned lesson. Follow your teacher’s teaching order.
Task steps and checks
Use your measured limits
- In CampusLightAlert.ino, update ALERT_ON_BELOW and ALERT_OFF_ABOVE from your own ranges. Keep ON lower than OFF and keep static_assert. For a checked LDR use SIMULATED_INPUT = false; for a teacher-approved potentiometer use true. Check the Serial label.
Test both ways into the middle
- Test below ON, above OFF and in between from both starting states. At exactly either limit, keep the previous state. Before running each test, write what you expect and why.
- Start high: alert switches OFF
- Move to the middle: stays OFF
- Start low: alert switches ON
- Move to the same middle: stays ON
Check your result: If hardware is unavailable, trace the rules as practice. A prediction does not count as a hardware test.
Revised weekly handout pages: 8.
Materials
CampusLightAlert.ino, LDR divider or potentiometer, Serial Monitor. · Individual student workbook and evidence folder; paired hardware, individual answers
Resources
Vocabulary
- threshold
- a limit used to choose an action
See it
More examples and practice
Swap roles and restate chosen limits · 5 minutes
Swap roles and restate the measured ranges. The code uses two thresholds, not a single crossing point: ALERT_ON_BELOW is lower than ALERT_OFF_ABOVE.
Swap roles and restate chosen limits.
Model ON below lower limit, OFF above upper limit · 8 minutes
If the LED is off and the reading falls below ON, turn it on. If it is on and the reading rises above OFF, turn it off. Between the limits, or exactly on either limit, keep the previous state. This remembered state prevents unnecessary switching.
Trace the sequence on a number line and repeat it with a different starting LED state. Explain the role of memory. Work the practice example before revealing its solution.
Practice limits: ON below 1400, OFF above 1800. Starting LED is OFF. Predict the sequence for readings 1600, 1300, 1600, 1800, 1900.
Reveal reasoning
OFF, ON, ON, ON, OFF. At 1600 the state is retained. The 1300 reading turns it on. Exact equality at 1800 also retains the state. Only a reading above 1800 turns it off. These example limits are not a calibration recommendation.
Students update code, upload and test three regions · 25 minutes
Set the two constants using your data, preserve the safety assertion and upload the saved version. For a real LDR set SIMULATED_INPUT=false; for a potentiometer set it true. Check that serial output names the correct route.
Complete page 8 using your selected limits and actual tests in the three regions. Save your version and evidence filename.
Practice
- Trace the sequence on a number line and repeat it with a different starting LED state. Explain the role of memory.
- Complete page 8 using your selected limits and actual tests in the three regions. Save your version and evidence filename.
Explain limits using measured data, not copied numbers · 12 minutes
Test below ON, above OFF and between the limits. For the middle region record the starting LED state because the result depends on it. Do not call unchanged middle-region output a fault without considering its history.
Explain limits using measured data, not copied numbers.
Save code version and serial evidence · 5 minutes
Save the code and serial screenshot. Explain the limits using your readings, not “the teacher’s numbers”. If the ranges overlap, revisit measurement and setup.
Why must a middle-region test include the starting LED state? Save the page and relevant evidence.
Why must a middle-region test include the starting LED state?
Week 3 Read and use the input
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.
- Page 7: record three real readings for each condition, the ranges, your proposed limit and the reason. Label simulated input if you used it.
- Page 8: record real tests in the three regions using your limits. Save your version and write the evidence filename.
You are finished when: Pages 7 and 8 are complete and your code version is saved.
Why this matters: Limits chosen from real readings are what make your alert trustworthy.
- Hardware stays at school.
Revised weekly handout pages: 7, 8.
Choose limits from input readings weekly feedback guide
Task-specific feedback guide, not official IB descriptors or an automatic criterion grade.
- Calibration evidence
- Three readings per low/high condition, ranges and route labels are recorded honestly in ADC counts.
- Response logic
- ON is below OFF; low, high and between-limit behaviour are explained and tested.
- Version and explanation
- Own code and serial evidence support the selected limits and any measurement limitations.
| Band | Observable evidence |
|---|---|
| 0 | No usable readings or threshold explanation are available yet. |
| 1–2 | A few values or code edits are shown, but the input route, ranges or threshold reason is mostly unclear. |
| 3–4 | Readings and limits are present with some justification. One response region, state history or evidence reference needs clearer checking. |
| 5–6 | Repeated readings support the chosen ordered limits. The three regions are checked, the input route is labelled and code/serial evidence is saved. |
| 7–8 | The student uses measured ranges to justify limits and explains state retention, equality and any overlap or saturation. Tests and versions are traceable; simulated input and uncalibrated counts are not presented as physical light accuracy. |