03. Arduino IDE 2 & First Upload
Install Arduino IDE 2, select board and port, Verify, Upload, and blink the onboard LED.
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.
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.
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.
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.
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.
Blink and LED_BUILTIN
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.
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.
| Symptom | Likely fix |
|---|---|
| No port listed | Data cable; reconnect; CH340 driver on clone boards; another USB socket |
| Board shows as Unknown | Select other board and port..., choose Arduino Uno and tick the port |
| Serial Monitor shows rubbish | Set the Monitor baud to match Serial.begin (9600) |
| Wrong board | Board drop-down or Tools -> Board -> Arduino Uno (or R4 Minima) |
| Compile error | Read first error; check ; and spelling |
| Upload not in sync | Close Monitor; correct port; retry |
| Debug button is grey | Normal for the Uno - nothing to fix |
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
- Connect the Uno to the PC with a USB data cable
- In the drop-down next to the Upload button, choose Arduino Uno and its COM port (or use Tools -> Board and Tools -> Port)
- Open File -> Examples -> 01.Basics -> Blink (or paste the worked sketch)
- Click Verify (the tick) and wait for Done compiling
- Click Upload (the arrow), wait for Done uploading, then watch the onboard L LED
Worked sketch
Download .inovoid 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
- LED_BUILTIN maps to the board onboard LED pin (usually 13).
- setup runs once after reset; loop repeats for as long as the board is powered.
- delay(1000) waits one second - fine for Blink; later lessons introduce millis for multi-task timing.
- No breadboard is required for this first upload.
Test and record evidence
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.
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.
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.
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.
Hello, Serial Monitor
Press Run. The first two lines appear once; the loop line appears every second until you press Stop.
Hello, Uno! setup() runs once. loop() runs again and again... loop() runs again and again...
Hello, Uno
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.
Hello, Uno! Ready to code.
print or println?
Serial.print stays on the same line; Serial.println finishes the line. Numbers print without quotes.
ABC D Total: 42
Wiring label
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.
********** * WILTEQ * **********
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 afterSerial.-printLnandprintlnare different names.'serial' was not declared in this scope- the same kind of mistake in a name.serialandSerialare different.
The simulator uses the same wording and adds a plain-English hint under each error.
Fix the three bugs
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.
Fixed! All three bugs found.
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 insetup().digitalWrite(pin, HIGH)ordigitalWrite(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.
Blink - the Lesson 03 sketch
Run it and watch the virtual LED next to the Serial Monitor.
Switch the LED on
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.
Make it blink
Now blink it: one second on, one second off, forever. The pinMode line is already there - the four lines you add go in loop(), because they must repeat.
Add a Serial trace
The blink works, but you cannot see the code's state from across the bench. Print ON and OFF each time the LED changes, so the Serial Monitor follows along. Remember to start Serial in setup(). This is Serial debugging - you will do much more of it in Lesson 06.
ON OFF ON OFF
Flash an S in Morse code
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.
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.