Running the Arduino development environment for the first time

Well, it may have seemed more complicated than it really was, but finally, you have your programming environment ready to work. It's time to create our first test, take a tour of it, and meet all its parts and structures.

On the first run, the Arduino development environment should look like this:

Running the Arduino development environment for the first time

Arduino development environment

Basically, it's divided into three sections:

  • The toolbar at the top with buttons for the more usual commands
  • The code editor in the middle, where you will write your sketch, as we commonly call an Arduino program's code
  • The message area at the bottom, where you will get information about the status of your sketch and possible location of errors in it

Let's take a closer look at each one of these zones so that you can begin to use them.

The toolbar

In the toolbar, you're going to find a total of six buttons to call the more usual commands of the development environment.

The toolbar

Buttons on the toolbar

From the left-hand side to the right-hand side, they are as follows:

  • Verify: This button is used to verify the syntax in your code and compile it if no errors are found.
  • Upload: You can click on this button to upload the resulting machine code to the Arduino microcontroller. It will compile the code if it has not been compiled previously.
  • New: This opens a new blank sketch.
  • Open…: This loads a previously saved sketch from the disk through the use of a pop-up menu.
  • Save: This saves the currently edited sketch to the disk.
  • Serial Monitor: This opens the Serial Monitor window that allows you to visualize the interchange of data in a serial communication between your computer and the Arduino board. We will learn more about this in Chapter 8, Communicating with Others.

The code editor

The code editor is the zone where most of your work will happen and where you will spend most of your time.

It is a multitab editor, which means that you can open more than one document at the same time on different tabs. You can find a small downward-pointing arrow icon on the right-hand side of the tabs area that unfolds a menu with different tab-related options, such as New and Rename, or helps you move along the currently opened tabs.

It is not a very powerful editor but has all the features that one can hope to find in a modern code editor nowadays, such as syntax highlighting, which means that the different parts and words of your code are going to be presented in different colors that will help you classify the different elements in it, making it clear what a reserved word, a variable, or a constant is.

Another feature I really appreciate and that makes your work much more comfortable is the highlighting of parentheses and bracket pairs when you put the cursor over one of them so that you can easily view the opening/closing pair of such constructions.

The code editor

The code editor showing syntax highlighting and the pop-up menu

These features apart, there are some other useful commands, such as Search in Reference, that take the word under the cursor and look for it in the Arduino Language Reference section on the Arduino website, showing you the help page of the reserved word or function.

There are other stylistic commands, such as Increase Indent, Decrease Indent, and Comment/Uncomment, which are available through the pop-up menu that is shown when you right-click on the editor area.

The message area

The message area is the zone where the Arduino development environment will tell you which errors it has found when trying to compile your code or any other issues it has found when trying to accomplish the command you asked for, for example, a communication error when uploading the machine code to the microcontroller board.

The message area

The message area showing a syntax error and line highlighted in the code editor

When the error is related to a line in your code, this will also be highlighted in the code editor, as shown in the previous screenshot.

The Arduino development environment will try its best to reference in the message area the line number where it thinks the error is. I say thinks, because the mistake is not always correctly located and, in some cases, it can be one or two lines before the line the message area is reporting. This is a typical situation when programing in C, but we will talk about it later on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.62.105