Arduino IDE – The software

We will see how to install and configure the Arduino IDE software, and in the end we will upload our first program to the Arduino board.

Let’s go to the download page first . Select the appropriate installation file for your operating system.

Arduino IDE download
Arduino IDE download

Start the installer, install the usb driver as well.

Arduino components
Arduino components

Next, then install.

When done, launch the IDE and click on the file menu. Here you can open an example or create a new sketch. Open the Examples / Basics / Blink sketch. For example, connect an ATmega328 card with a USB cable . In the Tools / Motherboard / Arduino AVR Boards menu, select your motherboard and port, then upload the program by clicking the upload button on the toolbar (right arrow).

Arduino - Select the motherboard.
Arduino – Select the motherboard.

All that happens in the program is that the LED turns on and off. Flashes every second.

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

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

Let’s look at the structure of the Arduino program.

The program must include two main functions, setup () and loop ().

The  setup ()  function is called only once, when the program starts. Here you can set the outputs and inputs, start using the libraries, etc. We can write program code here as well, but it will only run once. The data type of the setup function is void, about that a little later.

void setup()
{

}

The loop () function runs continuously after the setup function. This is the location of the main program. The data type of this is also void.

void loop()
{

}

Additional syntaxes

Comments are lines in the program that are used to inform yourself or others about the way the program works. They are ignored by the compiler, and not exported to the processor, so they don’t take up any space in the flash memory. There are two groups of comments.

// this is the single-line comment after the double slash.

/* it is a multiline comment,
 or block comment,
 written between asterisk-slash.
*/

The semicolon indicates the end of a statement. Forgetting semicolon will result in a compiler error. It should not be used after “#define” and “#include” because here the semicolon causes a compiler error.

#include <myLibrary.h>

#define myConstans 5

int myVariable = 12;

Curly brackets enclose related code snippets. The opening curly brace “{” must always be followed by a closing curly brace “}”. The Arduino IDE includes a convenient feature for checking the balance of curly parentheses. Just select a parenthesis, or click the insertion point immediately after the parenthesis and its logical pair will be highlighted. Pairless parentheses often cause mysterious, opaque compiler errors that are very difficult to find. Curly parentheses are incredibly important in program syntax due to their varied uses.

// e.g: function
void myFunction(arg) 
{
  // your code
}

// e.g: loop
while(true)
{
  // your code
}

// e.g: conditional execution
if(condition)
{
  // your code
}

You may need these:

The next section is about the inputs and outputs.