Week 2 · Lesson 1 · 55 minutes
Control the LED from Serial Monitor
I can send 1 and 0 to control the existing LED and record what actually happens.
Planned lesson. Follow your teacher’s teaching order.
Task steps and checks
Read the command and trace the light
- Keep the teacher-checked circuit and resistor. Set the real GPIO and checked on/off setting in SerialLED. Use its USB port at 115200. Select No line ending if available.
- Predict, then send 1, 0, 1 one at a time. Repeat the whole sequence. Keep the monitor message and the actual light in separate columns.
- Type 1
- Sketch chooses ON
- Pin uses checked level
- Look at the real LED
Check your result: If the monitor says LED ON but the LED stays dark, what do you know? The sketch accepted the command. You have not proved the light works.
Revised weekly handout pages: 1.
Materials
Working ESP32 and LED circuit with its existing series resistor, USB data cable, computer and Arduino IDE Serial Monitor. No physical button is needed. · One individual weekly handout; hardware may be shared in pairs.
Resources
Vocabulary
- serial input
- characters sent from the computer to the ESP32 over the serial connection
- state
- the current stored value, such as LED on or off
Original classroom model
From typed command to LED output
Use the existing teacher-checked LED GPIO, wiring and resistor. The on/off level must match your working circuit. This is the planned rule, not evidence of a completed test.
Use the buttons to step through. With scripts off, every frame remains readable.
Send 1
- Type 1
- Character match
- LED on
A 1 command sets the stored LED state to on. The output level depends on the teacher-checked on/off setting.
Read the diagram
- Type 1
- Character match
- LED on
Send 0
- Type 0
- Character match
- LED off
A 0 command sets the stored LED state to off. Record the actual light and monitor feedback separately.
Read the diagram
- Type 0
- Character match
- LED off
Does a printed LED ON message prove the physical LED is on?
Discuss before revealing
No. It shows the program accepted the command. Observe the real LED and record any mismatch.
More examples and practice
Start from the working LED · 5 minutes
The class has got the ESP32 and LED working. Open your own saved LED sketch and check your setup. This lesson introduces Serial Monitor input; do not record it as tested until you try it.
Physical buttons are not available. Keep the existing LED circuit and earlier timer design. If your own setup has a fault, record it and ask for a check before continuing.
Check the pin and predict the rule · 10 minutes
Keep the working LED wiring and its series resistor. Copy the actual LED GPIO from your saved working sketch; GPIO numbers are not header positions. The starter deliberately uses LED_PIN = -1 and will not compile until you replace it with your checked GPIO.
The teacher must verify the actual board, selected port, LED pin and on/off levels. LED_ACTIVE_HIGH = true assumes an external LED that lights when the GPIO is HIGH. If your known working circuit uses LOW for on, have the teacher confirm LED_ACTIVE_HIGH = false. Do not rewire just to match an example.
Unplug USB before any wiring change. Ask the teacher to check the circuit before reconnecting. Never connect 5 V to an ESP32 GPIO.
The rule is 1 = on and 0 = off. Type one character without quotation marks, then click Send or press Enter. The LED should keep its state until another valid command or a board reset.
Upload and try 1 and 0 · 20 minutes
Save a new copy of SerialLED. Set the checked LED pin and on/off setting, then upload. Open Serial Monitor on the same port at 115200 baud. The starter requests LED off when it starts.
Predict the sequence 1 → 0 → 1 before sending each command. Record the actual LED state and Serial Monitor feedback on page 1. Repeat the sequence once. A printed message alone is not proof that the physical LED lit.
Use No line ending if available. Newline, carriage return and both are also supported: the starter ignores those line-ending characters. If nothing appears, check the port and 115200 setting, then send 0.
Swap roles and check one fault · 15 minutes
Swap who types and who observes. Each student should send a command and record their own observation. Keep predicted results separate from real results.
If Serial Monitor reports LED ON but the light is off, compare the selected GPIO and on/off setting with your saved working sketch. Unplug USB before checking wiring, LED polarity or a loose connection. Do not change random wires while powered.
The monitor prints LED ON after 1, but you see no light. What can you honestly record?
Reveal reasoning
Record the message and the observed LED off separately. Check the configured pin and on/off setting against the working sketch; ask for a safe wiring check. The message shows the program accepted 1, not that the LED physically worked.
Save your own evidence · 5 minutes
Record your actual board, LED GPIO, on/off setting, port and saved filename. Finish page 1 with your predictions and observations or NOT TESTED, plus one check or next check. Keep this same record for lesson 2.
Week 2 · Serial input and LED control
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 1: finish your record of the 1 and 0 commands.
- Page 2: finish your record of the repeated and invalid commands.
- Check that you wrote your saved sketch name, what you predicted and what you saw.
- Write one fault with its check and fix, or one next check.
You are finished when: Both pages are complete with your own predictions and real observations.
Why this matters: Your reaction timer needs reliable input and a stored state. This week you show both work.
- You may share hardware, but write your own predictions, observations and contribution.
- Buttons are not available yet, so Serial Monitor is the input this week. Button wiring, reaction timing and false-start tests come later. Keep your completed timer design.
- Hardware stays at school.
Revised weekly handout pages: 1, 2.
Serial input and LED weekly feedback guide
Task-specific feedback guide, not official IB descriptors or an automatic criterion grade.
- Safe practical work
- The actual LED GPIO and on/off levels are checked, the existing resistor is retained, and power is off for any wiring change.
- Input and output evidence
- Predicted and observed results are distinct for 1, 0, repeated and invalid commands. Missing tests are marked NOT TESTED.
- Explanation and contribution
- The student explains how the program matches a command, saves code and records a useful check and their own contribution.
| Band | Observable evidence |
|---|---|
| 0 | No usable record is available yet. |
| 1–2 | Some parts or results are named, but the record is incomplete or predictions are confused with observations. |
| 3–4 | Most required tests and the saved filename are recorded. The input/output explanation or next check needs more detail. |
| 5–6 | Safe checks, saved code and a clear predicted/observed test record are present. The 1/0 rule and the student’s contribution are explained. |
| 7–8 | The record is precise and repeatable, including repeated and invalid commands and a reasoned fault check or improvement. Untested work is honestly identified. |