Crack the Code · Stage 4
Write, upload and modify your first Arduino sketch — make the on-board LED blink, explain each line, and modify it to meet a series of challenges.
Open this deck on the projector and press F for full-screen. N toggles speaker notes. The accompanying teacher guide is at /curriculum/crack-the-code/teacher/lessons/2.
Before this lesson:
/code/<short-id> and add it to your bookmarks bar./curriculum/crack-the-code/present/2 (?notes=1 for speaker notes).By the end of this lesson, every LED in this room will be blinking on a pattern you wrote.
Set the room up: ThinkerShields out, USB cables connected, IDE open. Build curiosity. Don't reveal the code yet — first ask students how they'd describe to a robot how to blink a light.
_01_Blink.ino).Read the success criteria out loud (one slide later). Tell students this is the foundation for every later lesson.
A computer does exactly what you tell it, in the order you tell it.
pinMode(12, OUTPUT) — prepare pin 12 to send current.digitalWrite(12, HIGH) — turn it on.delay(1000) — wait 1000 milliseconds.digitalWrite(12, LOW) — turn it off.delay(1000) — wait again.Use the human-as-robot demo: ask one student to be the Arduino, you read the lines, they act them out. This makes 'sequence' concrete.
_01_Blink.ino, click the arrow to upload.Do this live on the projector. Deliberately introduce a missing-semicolon bug halfway through, get the red error, point at it, fix it. This normalises errors.
Open the PRP 1 student page (link in the resources).
Get Blink working. Then try at least two challenges:
Project the student page URL clearly. Walk around: the most common failures are wrong board/port, missing semicolons, and unplugged USB cables. Don't fix problems — coach students to read the error message.
Fingers on three:
Cold-call answers. (1) Look at the line above the red one — missing ; or }. (2) Pin 13 is the ThinkerShield data-transmission LED; using it makes Blink confusing. (3) Verify only compiles; Upload sends it to the board.
delay() — use millis().int command (see _03_int.ino) to give pin 12 the name LED.analogWrite() on a PWM pin (3, 5, 6, 9, 10, 11) to fade the LED.Point fast finishers at _03_int.ino and _05_analog_input.ino. The millis() challenge previews PRP 4 and the alarm project — it's a great bridge.
Write two sentences in your workbook:
Collect a few sentences aloud — listen for the words setup, loop, pinMode. Note any students who still seem unsure for one-on-one support next lesson. Reset all USB cables to the trolley as students leave.
End of lesson 2
Tomorrow / next lesson: Inputs, outputs & the PRP activities.