Learning Goals 5 min
By the end of this lesson you will be able to:
- Download and install the Arduino IDE 2.x on a Windows, macOS or Linux computer.
- Connect the Arduino UNO over USB and select the correct Board and Port from the Tools menu.
- Upload the Blink sketch onto a real board and watch the on-board LED flash once per second.
Warm-Up 10 min
Last lesson we toured the Arduino UNO board and learned that a microcontroller is a tiny brain that does one focused job. Today we wake the brain up.
Quick-fire puzzle
Two things have changed in the sketch below compared to the classic Blink. What do you think they do?
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(200);
digitalWrite(LED_BUILTIN, LOW);
delay(200);
}Reveal the answer
Change 1: LED_BUILTIN is a friendly name the Arduino IDE already knows for the on-board LED — on the UNO this is pin 13, but on other boards it might be a different pin. Using LED_BUILTIN means the sketch works on any Arduino without you needing to remember the pin number.
Change 2: delay(200) instead of delay(1000) makes the LED blink five times faster — once every 0.4 s instead of every 2 s.
New Concept 20 min
The big idea — from screen to chip
The Arduino IDE (Integrated Development Environment) is the app you use to write Arduino sketches. Think of it like a kitchen: you write the recipe (your sketch), the IDE turns the recipe into something the chip can actually eat (called compiling), and the upload button serves that meal onto the board over the USB cable.
Three steps happen behind the scenes every time you press upload:
- Compile — your readable sketch is translated into machine code the ATmega328P understands.
- Upload — the IDE sends that machine code down the USB cable to the board.
- Run — the board resets and starts running your sketch from the first line of
setup().
Where the buttons are in the IDE
Open the Arduino IDE 2.x. The most important controls live in the top-left corner and the Tools menu:
| What | Where to find it | What it does |
|---|---|---|
| Verify (✓) | Top-left toolbar | Compiles your sketch but does not upload it — useful for spotting typos. |
| Upload (→) | Top-left toolbar, next to Verify | Compiles and sends the sketch to the board over USB. |
| Board selector | Top dropdown or Tools → Board | Tells the IDE which Arduino you are talking to. |
| Port selector | Same dropdown or Tools → Port | Tells the IDE which USB socket the board is plugged into. |
| Serial Monitor | Top-right toolbar (magnifying glass) | A two-way text window for talking to the board — we use this from Lesson 23. |
| Output panel | Bottom of the window | Shows messages from Verify and Upload, including any errors. |
Every sketch has these two functions
void setup() {
// runs ONCE when the board powers on or resets
}
void loop() {
// runs OVER and OVER, forever
}Why it matters
Uploading code is the moment when "letters on a screen" become "things happening in the real world". This is the difference between programming a website and programming an Arduino — what you write tonight, you can hold in your hand tomorrow.
Worked Example 20 min
Together with your teacher, walk through these exact steps. By the end of the walkthrough every student should have the on-board LED blinking.
- Open the Arduino IDE. Wait for it to finish starting up.
- File → New Sketch — a fresh window appears with empty
setup()andloop(). - Plug the UNO into your computer with the USB cable. A green power LED should light up on the board.
- From the top board dropdown choose Arduino UNO.
- From the port list choose the USB port the board is plugged into (it will be labelled
COMxon Windows or/dev/cu.usbmodem…on macOS). - Replace the empty sketch with the sketch below.
- Press the Verify tick — the Output panel should say
Done compiling. - Press the Upload arrow — the orange RX and TX LEDs on the board flicker for a few seconds.
- Watch the orange L LED. It should now blink once per second.
// Blink — your first uploaded sketch
const int LED_PIN = 13;
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
delay(1000);
}What the board does once the upload finishes:
On-board L LED: on for 1 second, off for 1 second, forever.
Step 5 — see the timing before you change it
Uploading takes a few seconds each time, so it pays to know what a change will look like before you make it. Drag the two sliders below and watch the LED. The sketch underneath the sliders is exactly the one you just uploaded, with your two numbers filled in.
One full cycle = 1000 + 1000 = 2000 msone flash every 2.0 s · lit 50% of the time
The sketch that produces this
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}Move a slider and this sketch changes with it. Those two numbers are the only difference between a lighthouse and a strobe.
Find the timing you want here first, then type those two numbers into the IDE and upload once.
What changed since last lesson? Nothing in the code — this is the same Blink sketch from ARD-L01-01. The difference is you have just uploaded it onto a real chip for the first time.
Basic 7 min
For each task, edit your Blink sketch, press Upload and watch the on-board LED. Do not move on until the LED actually does what the task asks.
Goal: Make the LED blink twice as fast as the default Blink.
The original Blink
on 1 s · off 1 s
Your goal — twice as fast
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}Challenge 1 7 min
Goal: Make the LED follow a heartbeat pattern — a quick double-blink, then a long pause, then repeat.
The original Blink
on 1 s · off 1 s
Your goal — heartbeat
two quick blinks, then a long pause
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
// blink twice quickly, then wait, then repeat
}Challenge 2 6 min
Goal: Three classmates pressed Upload, and all three got stuck. Work out what went wrong for each one.
- Classmate A sees this in the Output panel:
Failed uploading: no upload port provided. The sketch itself compiled fine. - Classmate B plugged in the board and the green power LED is on. But no new entry ever appears in the Port list, even after unplugging and replugging.
- Classmate C typed the sketch below. Verify stops with a red error message.
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500)
}For A and B, write the one thing they must change. For C, type the sketch in exactly as shown and press Verify. Read the error, fix it, then upload it to your own board.
It works if Classmate C's sketch says Done compiling., uploads, and the L LED is on for half a second, then off for half a second.
Challenge 3 15 min
Bring your ARD-L01-01 invention to life
Pull out the paper design of the smarter everyday object you sketched for last lesson's Extra Mission. Type in the Part 2 sketch you wrote on paper (or write one now). It should make the on-board LED simulate one output from your design:
- If your output is a buzzer that beeps every 5 seconds, blink the LED every 5 seconds.
- If your output is a motor that runs for 2 seconds when triggered, flash the LED for 2 seconds then off forever.
- If your output is a status indicator, use a long blink for "OK" and a fast double-blink for "alert".
Upload the sketch and demo it to a partner without telling them which invention it is.
It works if your partner can describe back to you what the LED behaviour represents in your invention.
Recap 5 min
You wrote your first uploaded sketch. The Arduino IDE compiled it into machine code, sent it down the USB cable, and the board ran it the moment it finished resetting. From now on, every lesson ends with code running on real hardware.
- Arduino IDE
- The free app you write, compile and upload Arduino sketches in.
- Compile
- Translate the sketch into machine code the microcontroller can run.
- Upload
- Send the compiled machine code over USB onto the board.
- Port
- The name your computer gives the USB connection — e.g.
COM3on Windows or/dev/cu.usbmodem14101on macOS. - Sketch file (
.ino) - The file extension the IDE saves your code in. Each sketch lives in its own folder.
Extra Mission 5 min
Part 1 — Design a one-light status code
Many devices talk to you with just one small light. A phone charger, a wireless speaker, a smoke alarm. Pick one device like this, real or invented. On paper, design the light code it should use.
Your design must include:
- The device's name and its one job.
- At least three states it needs to show, such as "charging", "full" and "error".
- A blink pattern for each state, with the on-time and off-time in milliseconds.
- A reason each pattern is easy to tell apart from the others.
Part 2 — Make it
Turn each state into its own Blink sketch for the on-board LED. Use only pinMode, digitalWrite and delay. Save them with clear names, such as status-charging. Upload each one and check the LED matches your design.
Bring back next class: your paper design, the saved sketches, and a screenshot of the Output panel showing Done uploading.