Digital output — Blink
Upload the _01_Blink.ino sketch and watch the D12 LED flash on for a
second, off for a second, forever. Then go deeper into the sketch:
- Pseudocode it. In plain English, how would you make the classroom lights blink on and off every ten seconds? (Turn the switch on → wait → turn it off → wait → repeat.) Now write the pseudocode for the Blink sketch itself.
- Make connections. Re-open
_01_Blink.inoand compare your pseudocode to the real code — same order? Similar steps? Different language? - Understand the code. Work out what each line means:
pinMode(12, OUTPUT)makes pin 12 send current out (to the LED);void loop() {starts the forever-loop;digitalWrite(12, HIGH)turns pin 12 on;delay(1000)waits 1000 milliseconds (1 second);digitalWrite(12, LOW)turns it off. - Label the IDE. Use the word bank to label the sketch title, status bar,
upload & verify buttons, Serial Monitor, comments, curly braces, the semicolon,
void setup, the debug area. - Flowchart it. Draw the flowchart for Blink (terminator → process → delay → …).
- Challenges. Then modify the sketch:
- change how long the LED is on for;
- change how long the LED is off for;
- make two LEDs flash on and off together (e.g. D12 and D8);
- make the LEDs "chase" each other from D12 down to D9;
- make the LEDs come on in pairs or your own pattern.
Get a partner or your teacher to tick off each challenge, then complete the self-reflection.
What you'll learn
Write and modify your first Arduino program. Make the D12 LED blink and explain what every line does.
What you'll make
- I can upload
_01_Blink.inoand see the LED flashing. - I can write pseudocode for the Blink program in plain English.
- I can change how long the LED is on for and how long it is off for.
- I can make two LEDs flash in a pattern.
What you need
Arduino Uno + MAAS ThinkerShield + USB cable, a laptop with the Arduino IDE, this curriculum page open in a tab.
Sample code
void setup() { // runs once when you press reset or power the board
pinMode(12, OUTPUT); // make digital pin 12 an output
}
void loop() { // runs over and over again, forever
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for one second (1000 milliseconds)
digitalWrite(12, LOW); // turn the LED off (LOW)
delay(1000); // wait for one second
}
Steps
- Plug your Arduino into the laptop with the USB cable. The red power light on the ThinkerShield should come on. If it doesn't, try a different USB cable.
- Open the Arduino IDE. Go to Tools → Board → Arduino Uno. Go to Tools → Port and
pick the port that says
usbmodem(Mac) or the COM port that appeared when you plugged in. - Open the Blink sketch. From this page, click
_01_Blink.inoin the Sample code list. Copy it (the Copy button at the top right of the snippet), paste it into a new Arduino IDE sketch. - Verify it. Click the tick (✓) button at the top-left of the IDE. The status bar at the
bottom should say "Done compiling". If it says "error", look at the red message —
usually it's a missing
;at the end of a line. - Upload it. Click the arrow (→) button next to the tick. The TX/RX LEDs on the board flash while it uploads; the status bar says "Done uploading".
- Watch the LED. Pin D12 on the ThinkerShield should be on for 1 second, off for 1 second, forever.
- Complete the IPO chart in your workbook.
- Write the pseudocode — in plain English, line by line, describe what your sketch does.
- Challenges — modify the sketch to:
- change how long the LED is on for (try 3 seconds);
- change how long the LED is off for (try ½ second);
- make two LEDs flash on and off together (pin 8 and pin 12);
- make the LEDs "chase" from pin 12 down to pin 9 in order;
- make a pattern of your own with three or more LEDs.
- Get it signed off. Show a partner or your teacher each challenge that works.
- Reflect — write two sentences in your workbook (see the reflection prompt).
IPO chart
Inputs
- None — Blink runs on a fixed timer (there is no sensor)
Processing
- void setup() runs once: set pin 12 as an OUTPUT with pinMode(12, OUTPUT)
- void loop() repeats forever: digitalWrite(12, HIGH) → delay(1000) → digitalWrite(12, LOW) → delay(1000)
Outputs
- LED on the ThinkerShield, pin D12
Stuck? Common things to check Tap to open
- "It says error so my code is broken" — usually it's one missing
;or}. Look at the line ABOVE the red one. - "Why isn't my LED working?" — wrong pin (sketches use 12, not 13), wrong board/port, USB cable not fully seated.
- "It compiled but nothing happens" — did you press Upload (→), not just Verify (✓)? They're different buttons.
Take it slower
- Don't worry about challenges 3–5 today. Get the basic Blink working and one delay change made.
- Pair up with a classmate — one types, one reads the line aloud.
- If you're stuck on a syntax error, ask a friend to look at the line above the red one.
Push further
- Use the
intcommand (see_03_int.ino) to give pin 12 a friendly name; rewrite Blink with the name. - Make the LEDs flash without
delay()— usemillis()so other things can happen at the same time. - Try
analogWrite()on a PWM pin (3, 5, 6, 9, 10, 11) to fade the LED in and out.
Done when…
You've finished PRP 1 when all of these are true:
- ☐ The D12 LED is flashing on your board.
- ☐ Your IPO chart is complete in your workbook.
- ☐ Your pseudocode is written in your workbook.
- ☐ You've attempted at least two of the five challenges.
- ☐ A partner or your teacher has signed off the working challenges.
- ☐ Your reflection is written.
Reflect
Write two sentences in your workbook:
- "Today I learned that an Arduino sketch always has ____ and ____."
- "The first challenge I want to try at home is ____."