Home · Academy · Robotics & Coding · Arduino · The Arduino IDE

The Arduino IDE

Learn the sketch structure in the Arduino IDE, choosing the board/port and uploading code.

LESSON COMPASS

What will you use this page for?

Core idea

The Arduino IDE is a free program where you write the code, check it, and send it to your Arduino board.

Evidence to produce

Complete the page task with your own input, test conditions and reasoning.

Control trap

Choosing the wrong port If the cable is plugged in but the wrong port is selected, the upload fails. To find the right port, unplug the cable, look at the menu, plug it back in, and select the option that newly appears. Choosing the wrong board If you select a board other than the Uno, the upload may fail even if…

Next connection

First Code: Blink — We will write and upload our first real program that turns the LED on the board on and off.

Module sources: Python Tutorial · Arduino Learn

LevelBeginner
Age10–16
Duration30–45 min
PrerequisiteBoards and Basic Components
ContentStandard lesson · 1,698 words
Last updated

One-sentence summary

The Arduino IDE is a free program where you write the code, check it, and send it to your Arduino board.

Why does it matter?

In the previous lesson you got to know the board and its basic components. But a board on its own does not know what to do. We tell it what to do with a program. The place where we write that program is called a development environment (in short, an IDE, "Integrated Development Environment").

The Arduino IDE runs on your computer. You write the code there, the IDE translates it into a language the board understands, and it sends the code to the board over the USB cable. In other words, the IDE is the bridge between you and the board.

We cannot start any Arduino project without knowing this bridge. That is why it is important to feel comfortable with the IDE before writing our first code. This lesson prepares a solid base for the "First Code: Blink" lesson.

The Arduino IDE interface

When you first open the Arduino IDE, you see several areas on the screen. Each one has a specific job.

The main areas

Everyday example: A kitchen

Think of the IDE as a kitchen. The editor is your counter, and your code is the recipe. The "Verify" button is like checking the recipe for missing ingredients before you cook. "Upload" is putting the dish in the oven. And the Serial Monitor is like watching through the oven door: it shows you what is happening inside.

Sketch structure: setup and loop

Every Arduino program is called a sketch, and it has two main parts. When you open a blank sketch, these two parts are already there.

void setup() {
  // Runs once: startup settings
}

void loop() {
  // Repeats forever
}

The setup() part

The commands inside setup() run only once when the board turns on. Here we make the startup settings: which pin is an input, which pin is an output, or whether serial communication should start.

The loop() part

The commands inside loop() repeat from top to bottom without stopping. This loop keeps running until the board is turned off. Repeating jobs, such as turning an LED on and off, go here.

Everyday example: A morning routine

setup() is like the preparations you do once: waking up, opening the curtains. loop() is like the things you repeat all day: eating whenever you are hungry. One happens once a day, the other happens over and over.

Even when both parts are empty, the sketch is still valid. The board does nothing, but the code has no errors.

Choosing the board and port

Before sending code, you need to tell the IDE two things: which board you are using and which USB port it is connected to.

Choosing the board

You choose your board by following "Tools > Board" in the top menu. For example, "Arduino Uno". If the wrong board is selected, the IDE prepares the code with the wrong translation rules and the upload fails.

Choosing the port

From the "Tools > Port" menu you choose the port your board is connected to. Before plugging in the USB cable, this menu may be empty. When you plug the cable in, a new option appears in the list; that one is your board.

Tip: If you cannot see the port, first check that the cable is fully plugged in and that it is a data cable (not a charge-only cable).

Verify and Upload

Getting the code onto the board happens in two steps.

Verify (compile)

The Verify button (the check mark) compiles your code. Compiling means translating the text you wrote into the machine language the board's processor understands. During this, the IDE also checks for typing errors. If there is an error, you see a red message in the output panel at the bottom and no upload happens.

Upload

The Upload button (the right arrow) first compiles the code, then sends it to the board over USB. During upload, the small LEDs on the board flash quickly. When you see the "Done uploading" message, your code is now running on the board.

void setup() {
  // No commands yet
}

void loop() {
  // No commands yet
}

You can Verify the empty sketch above and then Upload it. The board does not appear to do anything, but this is a great first test to confirm that the whole chain (writing, compiling, uploading) works.

The Serial Monitor

The Serial Monitor is a window that lets you see the text messages the board sends to the computer. You open it by clicking the magnifying-glass icon at the top right.

For the board to send messages, we first need to start serial communication inside setup():

void setup() {
  Serial.begin(9600);      // Start serial communication
  Serial.println("Hello Arduino");
}

void loop() {
  // Empty
}

Here the number 9600 is the communication speed (baud). The Serial Monitor must be set to the same speed, otherwise the message looks scrambled. The Serial Monitor is one of the tools you will use most to see what the board is "thinking". You can watch the value a sensor measures or which step the program is on from here.

Mini practice

In this practice the only goal is to get to know the IDE; we are not building a circuit yet.

  1. Open the Arduino IDE and create a blank sketch.
  2. Notice that the setup() and loop() parts are already there.
  3. Plug in the USB cable and select your board from "Tools > Board".
  4. Select the newly appeared port from "Tools > Port".
  5. Press the Verify button (check mark) and wait for the "Done compiling" message in the output panel.
  6. Press the Upload button (arrow) and see the "Done uploading" message.
  7. Add the lines Serial.begin(9600); and Serial.println("Hello Arduino"); inside setup(), then upload again.
  8. Open the Serial Monitor and see your message. Make sure the speed is 9600.

If you completed these steps, you have run every link of the Arduino chain.

Common mistakes

Choosing the wrong port

If the cable is plugged in but the wrong port is selected, the upload fails. To find the right port, unplug the cable, look at the menu, plug it back in, and select the option that newly appears.

Choosing the wrong board

If you select a board other than the Uno, the upload may fail even if compiling succeeds. Check the board name before uploading.

Mixing up setup and loop

Writing a setting that should run once inside loop(), or putting a repeating job inside setup(), is a common mistake. Ask yourself, "Once, or over and over?"

Forgetting the Serial Monitor speed

If you write 9600 in the code but set the Serial Monitor to a different speed, you see meaningless characters on the screen. The two speeds must match.

Forgetting the semicolon

In C/C++, most lines end with ;. If you forget it, Verify shows a red error. Look at the line number in the error message.

Safety note

Lesson summary

Review questions

  1. What is the Arduino IDE used for?
  2. What is the difference between the setup() and loop() parts?
  3. What two settings must you tell the IDE before uploading code?
  4. What is the difference between the Verify and Upload buttons?
  5. What must match between the code and the monitor so you can read a message in the Serial Monitor?

Answers

  1. It lets us write, compile, and upload code to the Arduino board over USB; it is the bridge between you and the board.
  2. setup() runs only once when the board turns on and makes the startup settings; loop() repeats without stopping to carry out the main work.
  3. You must select which board you are using (Tools > Board) and which USB port it is connected to (Tools > Port).
  4. Verify only compiles the code and checks for errors; Upload compiles the code and sends it to the board over USB.
  5. The communication speed (baud) must match; if the code says Serial.begin(9600), the Serial Monitor must also be set to 9600.

Source and verification note

For “The Arduino IDE”, verification focuses on whether the relationship between The Arduino IDE interface and Everyday example: A kitchen remains consistent across examples. Pin, voltage and current limits can differ between Arduino-compatible boards. Compiling code does not guarantee a safe circuit; loads such as motors and servos require a suitable driver and external power where appropriate.

Next lesson

First Code: Blink — We will write and upload our first real program that turns the LED on the board on and off.

Start QuizBack to Arduino
QUESTION POOL

Reinforce this lesson with 10 questions

This lesson has a pool of 20 questions. Each attempt selects 10 and reshuffles the choices.