Sub topic 3
A tour of the IDE interface
This chapter walks through the Arduino IDE window area by area. It assumes you have already installed the IDE (the previous chapter) and can open it on Windows, macOS, or Linux. It also assumes you know what a program is: a list of instructions a computer runs in order. You do not need a board connected yet. The tour covers Arduino IDE 2.x. Version 1.8.x looks different in places, and the chapter notes where.
By the end you will be able to name each part of the window, find the controls you will use in every session, and recognize the messages the IDE gives you while you work.
The big picture
The IDE is an editor, a compiler front end, and an uploader in one window. You write a sketch, which is the Arduino name for a program. The IDE turns it into machine code for your board's chip and sends that code over USB.
The window has six areas. Knowing their names makes the rest of the tutorial and most online help easier to follow.
The menu bar
The menu bar runs along the top of the window. On macOS it sits at the top of the screen, as in other Mac apps. Four menus matter most.
| Menu | What you use it for |
|---|---|
| File | New sketch, open a saved sketch, open built-in examples, save, preferences |
| Sketch | Verify/Compile, Upload, include a library, add a file |
| Tools | Pick the board and port, open the Serial Monitor, open the Boards Manager |
| Help | Getting started pages, reference, and the "About" dialog showing your IDE version |
The File > Examples submenu holds the sketches that ship with the IDE and with each installed board package or library. You will open one of them, Blink, in a later chapter. The Tools menu is where you will return most often. Its entries change depending on which board is selected, because each board family has its own options such as clock speed or memory layout.
The toolbar
The toolbar is a row of round buttons below the menu bar. From left to right in IDE 2.x:
- Verify (a check mark). Compiles the sketch and reports errors. It does not touch the board.
- Upload (a right arrow). Compiles the sketch if needed, then sends it to the board.
- Debug (a bug icon). Starts a debugging session. It works only on boards and probes that support it, and you can ignore it for now.
- Board and port selector. A drop-down showing the current board name and port, for example
Arduino Uno on COM3. Click it to pick a connected board. - Serial Plotter and Serial Monitor buttons at the far right.
The Verify and Upload distinction matters. Verify is safe to press at any time, with or without a board attached. Upload overwrites the program on the board, so it needs the right board and port selected.
The Serial Monitor button is a magnifying glass icon. The Serial Plotter draws incoming numbers as a live graph. You will use the monitor later in this tutorial.
In IDE 1.8.x the toolbar is a smaller strip of square buttons: Verify, Upload, New, Open, Save, and the Serial Monitor at the right. There is no board drop-down in that toolbar. You choose the board and port from the Tools menu instead.
The sidebar
The sidebar is the narrow vertical strip on the left edge. Each icon opens a panel that slides out next to the editor.
- Sketchbook lists the sketches saved in your sketchbook folder. Click one to open it.
- Boards Manager lists board packages you can install. A later chapter covers it.
- Library Manager lists libraries you can install. A later chapter covers this too.
- Debug shows variables and breakpoints during a debug session.
- Search finds text across the open sketch.
Clicking an icon a second time closes its panel and gives the space back to the editor. This is handy on a small laptop screen.
The editor and sketch tabs
The editor is the large central area where you type code. It does syntax highlighting: keywords such as void and if get one color, comments another, and strings another. It also offers auto-complete suggestions as you type and shows line numbers in the left margin.
A sketch can have more than one file. Each file appears as a tab above the editor. The main file has the same name as the sketch folder and ends in .ino. If you make a sketch called Demo, the folder is Demo/ and the main file is Demo/Demo.ino. The IDE enforces this naming. If you rename the .ino file so it no longer matches its folder, the IDE will offer to create a new folder for it.
New sketches start with this skeleton, which is exactly what the IDE gives you when you choose File > New Sketch:
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}This compiles as it is. It does nothing, but it is a valid sketch. The next chapters explain what setup() and loop() mean.
An unsaved change shows as a dot or marker on the tab. Press Ctrl+S (Cmd+S on macOS) to save. Upload and Verify do not require you to save first, but saving as a habit protects your work if the IDE or the computer crashes.
Some editor details are worth knowing early:
- Press Ctrl+/ (Cmd+/ on macOS) to comment or uncomment the selected lines.
- Press Ctrl+T (Cmd+T on macOS) to auto-format the code in IDE 1.8.x. In IDE 2.x, use Tools > Auto Format.
- Place the cursor on a function name and use the context menu to jump to its definition, where the IDE can find it.
The bottom panel
The bottom panel has two tabs that you will watch constantly.
Output shows what happens when you press Verify or Upload. A successful verify ends with a summary of memory use, like this:
Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.The two lines tell you how much of the board's flash memory (where the program is stored) and SRAM (working memory while it runs) your sketch uses. The numbers above are for an Uno. Other boards print different maximums. If a sketch is too large, the compile fails with a message that the sketch exceeds the available space.
Errors appear in the same panel in red text, with the file name and line number. For instance, a missing semicolon produces a message like expected ';' before '}' token. The reported line is often the line after the real mistake, because the compiler only notices the problem when it reaches the next token. When an error looks wrong, check the line above it.
Serial Monitor shows text that the board sends back over the USB connection, and lets you type text to send to the board. It is empty until a sketch prints something. A later chapter explains it in full.
The panel can be dragged taller or shorter, and you can close it with the panel toggle if you need more editor space.
The status bar
The status bar is the thin strip at the bottom edge. It shows the cursor position (line and column), the selected board, and the selected port, for example Arduino Uno on COM3. If no board is selected, it shows a message such as Select Board. It also has a notifications icon. Messages about updates, such as "a new version of a board package is available", collect there.
Glance at the status bar before every upload. It confirms the two settings that cause most upload problems: the wrong board and the wrong port.
Preferences worth knowing
Open File > Preferences (on macOS, Arduino IDE > Settings). Most defaults are fine. Three settings are useful to know about.
- Sketchbook location is the folder where new sketches are saved. By default it is
Arduinoinside your Documents folder. Libraries you install go into alibrariesfolder inside it. - Editor font size and interface scale help if text is small on a high-resolution display.
- Show verbose output during compile or upload prints the complete compiler and uploader commands in the Output tab. It is off by default. Turn it on when you need to diagnose a failing upload, because the extra lines show which tool ran and which port it used.
Changing a preference does not alter your sketches. Settings are stored per user, not per sketch.
Common mistakes on the tour
- Looking for a "Run" button. There is none. Arduino code does not run on your computer. It runs on the board, so you Upload instead.
- Pressing Upload with no board selected. The IDE reports that no board is selected or asks you to choose one. The fix is in the board and port selector, covered in later chapters.
- Reading the first error only partly. The Output tab can contain dozens of lines. The first line that says
error:is usually the real cause. Later errors often follow from it. - Confusing the sketch folder with the file. Moving only the
.inofile out of its folder breaks the naming rule and can hide additional tabs.
Practice
Exercise
You press Verify with no board attached, and the Output tab ends with "Sketch uses 924 bytes (2%) of program storage space." Has the program been sent to a board? Which button would do that, and why should you check the status bar first?
Show answer
No. Verify only compiles the sketch and reports memory use, so nothing was sent. Upload compiles and then sends the program to the board. Check the status bar first because it shows the selected board and port, and a wrong board or port is the most common cause of a failed upload.
Exercise
You create a sketch named Demo. What are the folder name and the main file name, and what does the IDE do if you rename only the .ino file to Test.ino?
Show answer
The folder is Demo and the main file is Demo/Demo.ino. If you rename only the file to Test.ino, the names no longer match, and the IDE offers to create a new folder named Test to hold it.