Module 1 - Getting Started

03. Arduino IDE 2 & First Upload

Install Arduino IDE 2, select board and port, Verify, Upload, and blink the onboard LED.

Estimated time 1 session + optional extrasIn class Week 1 · Session 2

Learning outcomes

  • Install and navigate Arduino IDE 2
  • Select the correct board definition and serial port
  • Explain the difference between Verify (compile) and Upload
  • Run the Blink sketch on LED_BUILTIN and diagnose common upload faults
  • Know when Library Manager is needed for later lessons

Parts and preparation

Arduino Uno, USB data cable and Arduino IDE 2 (desktop). No breadboard required for Blink.

Before power: inspect wiring, confirm supply voltage and ensure all connected circuits share GND.

Install Arduino IDE 2

Lab PCs usually have Arduino IDE 2 installed already - if yours does, skip to the next section.

On your own computer, download Arduino IDE 2 from arduino.cc/en/software and run the installer. If Windows asks whether to install USB drivers, choose Install - they let the PC talk to the board.

The first time the IDE opens it downloads a few files it needs, including support for the Uno. Wait until the progress messages at the bottom of the window stop before you try to upload.

Find your way around Arduino IDE 2

The IDE is where you write a sketch (an Arduino program), check it, and send it to the board. You only need a few parts of the window today.

The round buttons at the top left do the main jobs: the tick is Verify and the arrow is Upload. The third button, Debug, stays grey with the Uno - you can ignore it. Next to the buttons is the drop-down where you choose your board and port. The magnifying glass at the top right opens the Serial Monitor.

Under your code is the Output panel. It shows what happened when you clicked a button, including any error messages. A small pop-up at the bottom right says Done compiling or Done uploading when a job finishes.

A simplified Arduino IDE 2 window with eight numbered parts: the Verify tick button, the Upload arrow button, the greyed-out Debug button, the board and port drop-down set to Arduino Uno, the Serial Monitor magnifying glass at the top right, the Library Manager in the left sidebar, the Output panel under the code showing Sketch uses 924 bytes, and the status bar showing Arduino Uno on COM5
Verify, Upload, the board drop-down and the Output panel are the parts you use every lesson.

Your first reliable workflow

Follow the same five steps every time: plug in, choose board and port, Verify, Upload, watch. Most beginner upload problems come from skipping one of them.

If Verify finds a mistake, fix the first error and Verify again until it is clean. If Upload fails, go back to step 2 and check the cable, the board and the port.

Five steps in a row: 1 plug in with a USB data cable, 2 pick Arduino Uno and its COM port in the drop-down, 3 click the tick button to Verify until it says Done compiling, 4 click the arrow button to Upload while the TX and RX LEDs flicker until it says Done uploading, 5 watch the L LED blink. A red loop sends Verify errors back to Verify; a dashed loop sends upload failures back to step 2
Plug in -> Board and port -> Verify -> Upload -> Watch.

Verify vs Upload

Verify (the tick button) checks your sketch for mistakes and builds it into machine code, all on the computer. Nothing is sent to the board, so you can Verify with no Uno plugged in. When it works, the Output panel shows how much memory the sketch uses, for example Sketch uses 924 bytes (2%) of program storage space.

Upload (the arrow button) does the same check and build, then sends the code down the USB cable. The TX and RX LEDs on the Uno flicker while the data arrives. The board then resets and runs the new sketch from setup().

The third button, Debug, only works with certain boards, not the Uno, so it stays grey. You will not need it in this course.

Two rows. Verify, the tick button: the computer checks the code and builds it, the Output panel shows Sketch uses 924 bytes, and the Uno is not touched. Upload, the arrow button: the computer checks, builds and sends the code down the USB cable, the TX and RX LEDs flicker, the board resets and the new sketch starts at setup(), and the IDE says Done uploading. A note says the grey Debug button can be ignored on the Uno
Verify checks your code. Upload checks it and puts it on the board.

Board and port

The board and port drop-down sits next to the Upload button. Open it and pick your Uno. You can also use Tools -> Board and Tools -> Port.

Board tells the IDE what kind of board you have, so it builds the code for the right chip. Choose Arduino Uno (or UNO R4 Minima if that is your board). A wrong board gives confusing compile or upload errors.

Port tells the IDE which USB socket to send the upload to. On Windows ports are named COM3, COM5 and so on. A port only appears when the Uno is connected with a data cable - charge-only cables look plugged in but never show a port.

Which port is the Uno? Open the port list, unplug the Uno, and look again - the port that disappeared is yours. When both are set, the status bar at the bottom right says something like Arduino Uno on COM5.

The IDE 2 board drop-down opened next to the Verify, Upload and Debug buttons, listing Arduino Uno on COM5, Unknown on COM7 for a clone board, and Select other board and port. Beside it, Board means what kind of board, so the IDE builds for the right chip, and Port means which USB socket the upload goes to. Underneath, the unplug test: COM1 and COM5 are listed, after unplugging only COM1 is left, so COM5 is the Uno
Both Board and Port must match the hardware on your desk.
Reference - read if curious. You do not need it for class.

Clone boards and the CH340 driver

Many lab Unos are clones. Instead of the official USB chip they use a CH340 USB-to-serial chip. You still choose Arduino Uno as the board.

In the drop-down a clone may show as Unknown with a COM port. Click Select other board and port..., type Uno in the board search box, pick Arduino Uno, tick that COM port and click OK.

On most Windows PCs the CH340 driver installs by itself the first time you plug in. If no port appears with a known data cable, open Device Manager and look under Ports (COM & LPT) for USB-SERIAL CH340 (COMx). If it is missing or shows a warning icon, the driver is not installed - ask your facilitator, or install the CH340 driver from the chip maker (WCH) and plug in again.

Open the Serial Monitor

Sketches from the next lesson onwards print messages with Serial.println. To read them, click the magnifying-glass icon at the top right of the IDE (or Tools -> Serial Monitor). A panel opens under your code.

Set the baud rate drop-down in that panel to 9600, the same number as Serial.begin(9600) in the sketch. A wrong baud rate shows rubbish characters or nothing. If an upload fails with port busy, close the Serial Monitor and upload again.

The classic first sketch blinks the onboard L LED. LED_BUILTIN is a named constant for that pin (usually 13 on Uno). The board already includes a series resistor for L - no breadboard required.

setup() runs once after reset and configures the pin. loop() turns the LED on, waits, turns it off, waits, and repeats.

Close-up of the Uno near pin 13 showing the L LED, with pin 13 running through a built-in resistor to it, beside the Blink sketch annotated line by line and a timeline of pin 13 going HIGH and LOW each second as the L LED turns on and off
Watch the L LED after a successful Upload.
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

Reading error messages

When Verify fails, the Output panel lists error messages and the IDE highlights the line it is unhappy with. Scroll up to the first line that contains error: and fix that one - later messages are often knock-on effects.

An error line tells you where to look. For example, Blink.ino:8:3: error: expected ';' before 'digitalWrite' means line 8, character 3. The missing semicolon is actually at the end of line 7 - a missing ; is usually reported on the next line.

Case matters: setup, pinMode, HIGH and LOW must match exactly.

Upload errors such as not in sync or port busy: close Serial Monitor and other programs using the port, recheck Board/Port, try another USB socket or data cable, then retry.

SymptomLikely fix
No port listedData cable; reconnect; CH340 driver on clone boards; another USB socket
Board shows as UnknownSelect other board and port..., choose Arduino Uno and tick the port
Serial Monitor shows rubbishSet the Monitor baud to match Serial.begin (9600)
Wrong boardBoard drop-down or Tools -> Board -> Arduino Uno (or R4 Minima)
Compile errorRead first error; check ; and spelling
Upload not in syncClose Monitor; correct port; retry
Debug button is greyNormal for the Uno - nothing to fix
Reference - read if curious. You do not need it for class.

Library Manager (preview)

Later lessons install third-party libraries with the Library Manager: the books icon in the left sidebar, or Tools -> Manage Libraries. Each of those lessons names the exact Library Manager title and author. Install only that package - similarly named libraries often use different APIs.

Blink itself needs no extra library.

Wiring and safe build sequence

  1. Connect the Uno to the PC with a USB data cable
  2. In the drop-down next to the Upload button, choose Arduino Uno and its COM port (or use Tools -> Board and Tools -> Port)
  3. Open File -> Examples -> 01.Basics -> Blink (or paste the worked sketch)
  4. Click Verify (the tick) and wait for Done compiling
  5. Click Upload (the arrow), wait for Done uploading, then watch the onboard L LED
Power rule: switch off before moving wires. Arduino I/O pins are control signals; high-current loads require a driver and suitable external supply.

Worked sketch

Download .ino
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // LED on
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);   // LED off
  delay(1000);
}

How the code works

  1. LED_BUILTIN maps to the board onboard LED pin (usually 13).
  2. setup runs once after reset; loop repeats for as long as the board is powered.
  3. delay(1000) waits one second - fine for Blink; later lessons introduce millis for multi-task timing.
  4. No breadboard is required for this first upload.

Test and record evidence

Expected result: After Upload, the onboard L LED is on for about one second and off for about one second, repeating.

Practical evidence checklist

Common faults and checks
  • Port not found: reconnect with a known data cable; try another USB port.
  • Not in sync: verify Uno and port selections, close other serial programs, retry.
  • Compilation error: read the first error, not only the final summary.
  • Upload OK but no blink: confirm you uploaded Blink (not an empty sketch) and look at the L LED near pin 13.
  • Debug button is grey: normal for the Uno - only Verify and Upload are needed.
Challenge (extension - optional): Change the sketch to produce two short flashes (200 ms on) followed by a one-second pause, then repeat.

Check your understanding

Q1. What does Verify do?

Show answer

Compiles the sketch and reports errors without uploading.

Q2. Which toolbar button is Upload?

Show answer

The round button with the right arrow, next to the tick (Verify).

Q3. What is the difference between board and port selection?

Show answer

Board selects the target hardware definition; port selects the connected USB device.

Q4. What does LED_BUILTIN refer to?

Show answer

The pin connected to the board onboard LED (usually pin 13 on Uno).

Q5. Name one common cause of a missing port.

Show answer

A charge-only USB cable, missing drivers, or the board not connected.

Q6. Why read the first compiler error first?

Show answer

Later errors are often knock-on effects of the first mistake.

Code Along 1: Sketch Structure & Serial Output

Practise in your browser

Write and test this lesson's code on a virtual Uno. Work through the 7 exercises in order. Press Test and each one checks itself.

Exercises passed 0 / 7About 60-75 minOpen as its own page

Every sketch has two parts

When the Uno powers up or is reset, it runs setup() once, then runs loop() over and over for as long as it has power. Code that prepares the board - pin modes, Serial.begin(9600) - goes in setup(). The work the board repeats goes in loop().

The Serial Monitor is your window into the running sketch. Serial.begin(9600) opens the connection at 9600 baud, and Serial.println(...) sends a line of text to it.

Start (power on, reset or a new upload) leads to setup(), which runs once, then loop(), which runs again and again; beside it the Blink sketch with the setup() lines marked 1 time and the loop() lines marked over and over, and a timeline of one setup() followed by repeating loop() blocks
setup() runs once after reset; loop() repeats forever.
Worked example

Hello, Serial Monitor

Press Run. The first two lines appear once; the loop line appears every second until you press Stop.

void setup() {
  Serial.begin(9600);
  Serial.println("Hello, Uno!");
  Serial.println("setup() runs once.");
}

void loop() {
  Serial.println("loop() runs again and again...");
  delay(1000);
}

Turn on JavaScript to edit, run and test this code in the browser.

Expected output
Hello, Uno!
setup() runs once.
loop() runs again and again...
loop() runs again and again...
Exercise 1.1

Hello, Uno

Not started

Make the sketch print exactly two lines, once, when the board starts:

  • Hello, Uno!
  • Ready to code.

Text must match exactly - capital letters, spaces and punctuation included.

Sample output
Hello, Uno!
Ready to code.
void setup() {
  Serial.begin(9600);
  // Print the two lines here

}

void loop() {
}

Turn on JavaScript to edit, run and test this code in the browser.

Worked example

print or println?

Serial.print stays on the same line; Serial.println finishes the line. Numbers print without quotes.

void setup() {
  Serial.begin(9600);
  Serial.print("A");
  Serial.print("B");
  Serial.println("C");
  Serial.println("D");
  Serial.print("Total: ");
  Serial.println(42);
}

void loop() {
}

Turn on JavaScript to edit, run and test this code in the browser.

Expected output
ABC
D
Total: 42
Exercise 1.2

Wiring label

Not started

Print this three-line label for your breadboard, once.

Build the middle line in three pieces: Serial.print for the * at the start, Serial.print for the word WILTEQ, then Serial.println for the * at the end - println also finishes the line.

Sample output
**********
* WILTEQ *
**********
void setup() {
  Serial.begin(9600);
  // Top line

  // Middle line - print, print, then println

  // Bottom line

}

void loop() {
}

Turn on JavaScript to edit, run and test this code in the browser.

Reading compiler errors

When a sketch will not compile, the Arduino IDE shows an error with a line number. Fix the first error first - later errors are often caused by it.

  • expected ';' before 'Serial' - a semicolon is missing, usually at the end of the line above.
  • a function-definition is not allowed here before '{' token - the function above was never closed with }, so the next one starts inside it.
  • 'class HardwareSerial' has no member named 'printLn' - a spelling or capital-letter mistake after Serial. - printLn and println are different names.
  • 'serial' was not declared in this scope - the same kind of mistake in a name. serial and Serial are different.

The simulator uses the same wording and adds a plain-English hint under each error.

Four common compile mistakes - wrong case, a missing semicolon, a missing brace and unhelpful comments - each with the compiler message and the fix
Case, semicolons, braces, comments. Fix the first error, then compile again.
Exercise 1.3

Fix the three bugs

Not started

This sketch has three mistakes, so it does not compile. Press Run to see the first error, fix it, and repeat until the sketch prints the two lines in the sample. Do not change the text in quotes.

Sample output
Fixed!
All three bugs found.
void setup() {
  Serial.begin(9600)
  Serial.printLn("Fixed!");
  Serial.println("All three bugs found.");

void loop() {
}

Turn on JavaScript to edit, run and test this code in the browser.

Switching a pin on and off

A digital pin is either HIGH (about 5 V) or LOW (0 V). Two functions do the work:

  • pinMode(pin, OUTPUT) tells the Uno that the pin will drive something. It belongs in setup().
  • digitalWrite(pin, HIGH) or digitalWrite(pin, LOW) switches it.

LED_BUILTIN is the LED soldered onto the board, on pin 13. delay(1000) waits one second before the next line runs.

Exercise 1.4

Switch the LED on

Not started

Switch the onboard LED (LED_BUILTIN) on and leave it on. Two lines in setup(): make the pin an output, then drive it HIGH. Leave loop() empty.

void setup() {
  // Make LED_BUILTIN an output, then switch it on

}

void loop() {
}

Turn on JavaScript to edit, run and test this code in the browser.

Exercise 1.7

Flash an S in Morse code

Not started

The letter S in Morse code is three short flashes. The first flash is written for you: 200 ms on, 200 ms off. Add the second and third flashes, then keep the LED off for a full 1 second before the pattern repeats.

The test measures the timing, so the delays must be exact.

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // Flash 1 - done for you
  digitalWrite(LED_BUILTIN, HIGH);
  delay(200);
  digitalWrite(LED_BUILTIN, LOW);
  delay(200);

  // Flash 2 and flash 3 go here


  // In your third copy, change the last delay(200) to delay(1000)

}

Turn on JavaScript to edit, run and test this code in the browser.

Try it on a real Uno

Download Add a Serial trace, upload it to your Uno and open the Serial Monitor at 9600 baud. The LED and the ON/OFF lines should stay in step. Change both delays to 250 and upload again - Serial debugging lets you confirm the timing without a stopwatch.

Want more? Code Along chapter 1 has a Deeper exercise that goes further than this lesson. It is optional.