← Exit
/ Space navigate · n notes · f fullscreen · Esc exit

Crack the Code · Stage 4

Weeks 1–2 · First code — Blink, the IDE & binary

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.

TE4-4DPTE4-7DITE4-DES-01TE4-DIG-02

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:

  • Open the Blink sketch at /code/<short-id> and add it to your bookmarks bar.
  • Open the PRP 1 student page in another tab — that's what students follow today.
  • Open the slide deck: /curriculum/crack-the-code/present/2 (?notes=1 for speaker notes).
  • Plug in your demo board and verify uploading works before the bell.
  • Have a small batch of spare USB cables ready (one in six fails).
hook 2 min

Can you make a light blink with code?

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.

intention 1 min

Today you'll…

  • Upload your first Arduino sketch (_01_Blink.ino).
  • Explain what each line does.
  • Modify the sketch to meet four challenges.

Read the success criteria out loud (one slide later). Tell students this is the foundation for every later lesson.

concept 3 min

Sequence — instructions run top to bottom

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.
  • …forever.

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.

demo 5 min

Watch me upload Blink

  1. Plug in the board.
  2. Tools → Board → Arduino Uno.
  3. Tools → Port → usbmodem.
  4. Open _01_Blink.ino, click the arrow to upload.
  5. Watch the D12 LED on the ThinkerShield.

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.

task 25 min

Your turn — PRP 1

Open the PRP 1 student page (link in the resources).

Get Blink working. Then try at least two challenges:

  • change how long the LED is on for;
  • change how long the LED is off for;
  • flash two LEDs together (pins 8 and 12);
  • make LEDs chase from pin 12 down to pin 9;
  • your own pattern.

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.

check 3 min

Quick check

Fingers on three:

  1. The Arduino IDE highlights an error. What's the first thing you check?
  2. Why do we use pin 12, not pin 13?
  3. What's the difference between Verify and Upload?

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.

extension 5 min

Early finisher? Try this.

  • Make the LEDs flash without delay() — use millis().
  • Use the int command (see _03_int.ino) to give pin 12 the name LED.
  • Try 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.

reflect 3 min

Before you pack up

Write two sentences in your workbook:

  1. "Today I learned that an Arduino sketch always has ____ and ____."
  2. "Next lesson I want to try ____."

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

That's it.

Tomorrow / next lesson: Inputs, outputs & the PRP activities.