The Arduino IDE is where Arduino programs are written and uploaded to the Arduino board. In this article, we will see how to download, install, and configure the Arduino IDE. We will also see how to write a basic Arduino program and how to upload a program to the Arduino.

How to Install the Arduino IDE

The Arduino IDE is a free download from the website:

Arduino IDE Download Page.png

If you have a Windows system, download the Windows installer package. This will install the IDE on your computer just like any other program. However, this will only work if you have permission to install programs on your computer.

If you don’t have permission to install programs on your computer, download the Windows ZIP file for non-admin install file. This will keep the program files in a folder without actually installing them. The IDE can be opened by clicking on the arduino.exe file inside the folder.

There is also a Windows store app, which works just like the other versions. For Mac users, download and install the file for Mac OS X. Linux users can download the file for 32 bit, 64 bit or ARM systems.

How to Configure the Arduino IDE

Arduino IDE.png

After the IDE is installed, the first thing to do is set the board type to the model of Arduino you’ll be using. Sketches need to be compiled differently depending on the microcontroller. Setting the board type tells the IDE which microcontroller your Arduino has so it can compile the sketch accordingly.

To set your board type, go to Tools > Board, and choose the model of Arduino you have. For example, if you have an Arduino UNO choose Arduino/Genuino UNO:

Setting up the Arduino IDE - Setting the Board Type.png

Now we need to tell the IDE which USB port to use for sending data to the Arduino. The Arduino needs to be connected to the computer with a USB cable to do this. Once it’s connected, go to Tools > Port and select the COM port that has your board type next to it:

Setting up the Arduino IDE - Setting the COM Port.png

That’s all the configuration that needs to be done.

Example Sketches

There are lots of good example sketches that come with the Arduino IDE. These are pre-written programs that can be used to do things like blink LEDs, control servos, and write to LCD displays. To find the example sketches, go to File > Examples:

Setting up the Arduino IDE - Example Sketches.png

How to Write an Arduino Program

Every Arduino sketch needs a setup() function and a loop() function to work properly.

The setup() function is executed only once, when the program starts. This is where we put code that doesn’t change throughout the program, like the code for setting pins as inputs and outputs, initializing the serial monitor, and initializing sensors.

In the sketch, the setup() function is always placed before the loop() function:

Setting up the Arduino IDE - void setup().png

The other essential part of every sketch is the loop() function. The loop() function is the main part of the sketch, where most of the code will go. The code in the loop() function is executed over and over again in an infinite loop.

The syntax for the loop() function is similar to the setup() function. The code you want to run in the loop goes inside the two curly brackets:

Setting up the Arduino IDE void loop.png

When the Arduino runs this sketch, the code in the setup() function will be run once, then the code in the loop() function will be run over and over until the power is shut off or we give it a command to exit the loop.

How to Write Comments

Comments are pieces of text in a program that do not get executed. They’re a good way to keep notes and make it easier for other people to understand your code.

There are two ways to make a comment. The first way is to type two forward slashes (//) before the text you want to be a comment:

void loop(){
  // this is a comment

Any text after the // is ignored by the Arduino when the program is run.

Multi-line comments can be made by typing a /* followed by a */ like this:

 * this is a multi-line
 * comment

Any text between the two asterisks will be recognized by the IDE as a comment. Multi-line comments are usually used at the beginning of a sketch to explain how it works and how to connect any external devices.

How to Upload Your Sketch to the Arduino

After the sketch has been written, the next step is to upload it to the Arduino. To upload a sketch, click the arrow button in the upper left side of the window:

Setting up the Arduino IDE - Upload Button.png

The IDE will then verify your code by checking for any typos or syntax errors. If it finds an error, it will let you know with an orange error message like this:

Setting up the Arduino IDE - Error Message.png

If the code is correct and free of any errors, the IDE will compile the sketch. Compiling is the process of converting human readable code like C and C++ into machine readable code that the microcontroller can understand.

After the sketch has been compiled, the IDE transfers the code through the USB port to the Arduino where it is saved in the ATMEGA328’s flash memory. The sketch starts running right away and keeps running until the power is removed.

The sketch is saved in the Arduino’s flash memory, so it will stay in memory even after the power has been removed. The next time the Arduino is powered on, the same sketch will start running again.

Hope this article has helped you get the Arduino IDE setup and working! Be sure to leave a comment below if you have any questions…