View Course Path

Arduino IDE – Complete guide to setup and get started

Now that you are familiar with the Arduino Uno pins and hardware, it is time to dive into the software end of things. We know that once we have the board, to do anything with it, we need to program it. This means the microcontroller needs to be fed with some code. There are two aspects to this. The first is understanding how to program an Arduino. The second one is learning more about the Arduino IDE. The IDE is a platform that handles the writing, debugging and the uploading of the code, among other things. In this post, we will focus on the latter. Let’s get introduced to the Arduino IDE and set up our workstation.

What is Arduino?

Arduino Logo

To reiterate from our introduction to Arduino, the Arduino is an open-source hardware and software company. This company provides development boards like the UNO, that help us play around with microcontrollers. The company designs micro-controller kits for developing digital devices.

These Arduino boards can get inputs from various devices such as sensors. They contain microcontrollers that can process the input data according to the program coded into it. With that data, it can control outputs like LED blinking and activation of DC motor, etc.

Moreover, there are a variety of Arduino boards available. They differ in terms of their features. Some of the Arduino development boards are listed below:

  • Arduino-Uno
  • Leonardo
  • Arduino 101
  • Esplora
  • Arduino Micro
  • Arduino Nano
  • Mega 2560
  • Arduino Zero
  • Arduino Due

How to program an Arduino?

An Arduino board is programmed using the Arduino IDE. In short, the first thing you do is open up the Arduino IDE software on your computer. Next, you open a new sketch File by clicking New. Write the code. Compile it. Select your board to be programmed. And then upload the code to the board.

This is the general procedure. Let’s dive into the details now.

Which language do we use to program an Arduino?

We use Embedded C to write Arduino programs. Embedded C finds applications in cases where the coding is very near to the hardware. This means that the language directly communicates with the hardware. This showcases its similarity to C++ with the addition of some methods and functions. The Arduino programming language has some built-in functions other than normal functions used in ordinary C++. It can support both C and C++ languages.

What is the Arduino IDE?

arduino sketch sample

The Arduino Integrated Development Environment (IDE) is an open-source software specially designed for writing and compiling the code into the Arduino development board. It is surprisingly easy to code in Arduino’s IDE even if you don’t have any prior knowledge about the Arduino. If you are starting with a basic knowledge of C programming, then mastering Arduino programming should not take more than 12 hours.

An Arduino code is called a sketch. Furthermore, upon compiling, this sketch will create a Hex file that can control the hardware.

How to install the Arduino IDE  in Windows?

The Arduino IDE software is readily available online for all operating systems like MAC OS, Windows, Linux. Additionally, it and also can run on the Java platform. Follow the steps below to install the Arduino IDE on your Windows device.

  • Download the correct and latest version of Arduino IDE software from the Arduino website according to your PC’s specifications. It is available for both 32-bit and 64-bit systems.
  • After downloading the IDE software, open the .exe file. Then proceed with the installation and please wait for the driver installation process to finish.
  • Click on the ‘I Agree’ button on the license agreement.
  • Select all the components to install and click on the ‘Next’ button.

components installation

  • Next, select the location in which you want the program to be installed by entering the path or by browsing the path. It’s better to keep the default one.

Arduino IDE installation folder

  • After installation completes, click on the ‘close’ button. The setup window will extract and install all the required files.

IDE installation

  • Furthermore, create the shortcut folder on your desktop or wherever you want. Now, the Arduino IDE is installed on your PC. Just click on it, the IDE will open up.

Understanding the Arduino IDE interface

Parts of the Arduino IDE window

 

The IDE environment is mainly divided into three sections

  • Dropdown menus/Toolbar
  • Editor screen
  • Error window

Dropdown menus/Toolbar

It contains five important menus, along with a few quick access buttons. The dropdown menus are:

  • File
  • Edit
  • Sketch
  • Tools
  • Help

Each of them contains several options. Let’s familiarize ourselves with them.

1) File

file drop down menu arduino IDE

      Options Function
New Creates a new sketch
Open It allows you to open the pre-existed sketches by browsing through the computer drivers and folders.
Open Recent Provide the most recent sketches.
Sketchbook Shows all sketches that are available in the sketchbook folder
Examples All example codes that are provided by the Arduino IDE. All these examples are arranged in a tree. So that you can easily access them by using topics or library.
Close Close the current sketch.
Save This saves the sketch with the same name.
Save as You can save the sketch with a different name
Page Setup It shows the Page Setup window for printing purpose
Print Allows the printer the print the current sketch
Preferences Clicking on this option will open the preferences window where you can customize the settings such as the language of the IDE interface.
Quit Closes all IDE windows

2) Edit

edit menu arduino ide

      Options Function
Undo/redo You can go backwards or forward for one or more steps while editing using Undo and Redo respectively
Cut Removes the selected content from the sketch and paste it on the clipboard
Copy Duplicates the selected content and paste it on the clipboard
Copy for forum Copies the code and paste it on the clipboard in a form that is suitable for posting to the forum
Copy as HTML Copies the code and paste it on the clipboard in a form that is suitable for webpages as in HTML
Paste Pastes the content from the clipboard at the cursor position
Select all Select the entire sketch
Comment/Uncomment Puts and remove the comment symbol // at the beginning of the selected line
Increase/decrease Indent It can add and remove the space at the beginning of the selected line.
Find Using this, you can find the required text in your sketch.
Find Next Highlights the next occurrence of the specified  string
Find Previous Highlights the previous occurrence of the specified string

3) Sketch

sketch menu

      Options Function
Verify/Compile It checks the errors present in your sketch and informs you about the memory space occupied by the variables via the console window.
Upload It automatically compiles and loads the code into the selected Arduino hardware through the port
Upload using programmer It will overwrite the bootloader present on the board. Use the Burn Bootloader tool to restore it. So that the bootloader can occupy the full flash memory capacity.
Export Compiled Binary It will save the file as .hex file and send it to your Arduino board using other tools.
Show Sketch Folder It will open the currently opened sketch folder
Include Library It allows you to insert the library file either from your device.
Add File It allows you to add the source file to the sketch

4) Tools

tools menu

Autoformat It will correct the indentations of the curly braces.
Archive Sketch It saves the current sketch as a zip file.
Fix Encoding and Reload It will fix the discrepancies between the editor char maps and the operating system char maps
Serial Monitor It will open the serial monitor that is the output screen
Board Select the  correct board that you are using at that time
Port It contains all of the serial devices that are connected with your device
Programmer It is used to select the hardware programmer while programming the board without USB serial connection.
Burn Bootloader It allows you to burn a bootloader into the microcontroller.

5) Help

help menu

It is used to get the documents that come along with the Arduino IDE. So that you can get access to view,

  • Getting Started (Galileo & Edison help)
  • Environment
  • Troubleshooting( Galileo & Edison help)
  • Reference
  • Find in Reference
  • FAQ
  • Visit Arduino.cc
  • About Arduino

Below the dropdown menus, you can see a bar that has five basic and important options. They are,

tool bar on the Arduino IDE

Icon Name Function
verify Verify It compiles the code and lets you know about the errors through the error window.
upload Upload It uploads the code into the connected Arduino hardware. When you click this button, It will automatically compile the code before uploading into the Arduino board
new New It creates a new sketch
open Open It can show a menu of all the sketches that you already did. Clicking on one file will open it within the currently opened window by overwriting the pre-existing content.
save Save It can save your sketch
serial monitor Serial monitor Clicking on this button will show the serial monitor, which is the output screen.

What are Libraries?

Libraries are simply a collection of code that helps you to interface the hardware with any peripheral devices such as sensors, modules, shields, etc. easily. You can use built-in functions of the libraries to make a coding project much more comfortable. Think of these as files that add extra features to your coding ability. These files reduce the effort that you need to code by providing tailor mode code functions. For example, if you want to interface an LCD with the Arduino Uno, you can just use a library where certain functions are pre-defined. You can just insert these functions as they are and don’t have to code everything from scratch. Intuitive.

How to install a library in the Arduino IDE?

There are a couple of ways to install a library for the Arduino IDE. You will need to do this whenever you are using a unique device or a shield from one of the plethora of Arduino shields available.

How to install the library from the library manager in the Arduino IDE?

Installing library in Arduino IDE method 1

  • Open the Arduino IDE software.
  • Go to the sketch menu and click on Include Library option.
  • Click on Manage Libraries.
  • You will see the list of already installed libraries, click on the needed library.
  • Select the latest version of the library you needed.

Library Manager

How to import the library from a zip file?

  • Open the Arduino IDE software.
  • Go to the sketch menu and click on Include Library option.
  • Click on Add .zip Library options.
  • Then, select the correct .zip library by navigating the location.
  • Open the .zip library file. Now you can find it that library in Include Library option.

How to install the library file manually?

installing library from zip

  • Download the library file as .zip format that is available online. It contains a .cpp file, a .h file, example folder, and a .txt file.
  • Expand it and save it in the proper directory.
  • Go to the File menu and click on Preferences and to sketchbook location.
  • Change the directory of your sketchbook folder.
  • Click on the .zip folder and decompress it.
  • Copy the library file that is named as the same library name and paste it in your sketchbook folder.
  • Now you can find it that library in Include Library option.

How to install boards in the Arduino IDE’s Boards Manager?

Whenever you shift from using an Arduino Uno to a Mega or a Nano or any other Arduino board, you will need to select it from the Boards menu. In fact, if you use a third party board with the Arduino IDE (yes that’s possible), then you need to install the board into your Boards Manager to be able to use it properly. There are a couple of ways of doing this.

How to install boards from the board manager?

selecting a board

  • Open the Arduino IDE software.
  • Go to Tools menu and click on Boards option.
  • Then click on the Boards manager. It will show the list of boards.
  • Select the Board you need to connect.
  • Click on the Install option. Now the board is installed in your Arduino IDE.

How to install boards using URL?

board installation using url

In some cases, you couldn’t find the device you want to connect through the board manager. In such cases, you need to add them manually using the URL.

  • Open the Arduino IDE software.
  • Go to the Files menu and click on the preferences option.
  • Paste the URL of the board’s installation package. You should be able to find this on the official page of the vendor from where you got the board.
  • Click on Ok option.
  • Go to Tools menu and click on Boards option then click Boards manager.
  • Now you can find that board by searching in the search bar and click on Install option.

How to select the board?

how to select board

  • Open the Arduino IDE software.
  • Go to Tools menu and click on Boards option. It will show the list of boards
  • Select the board that is connected with the device by clicking on it.

How to select programmers in Arduino IDE?

selecting a programmer in Arduino

You can also use an external programmer such as AVR-ISP, STK500 where it is possible to burn sketches to the hardware without using the bootloader.

  • Open the Arduino IDE software.
  • Go to Tools menu and click on Programmer option. It will show the list of Programmers.
  • Select the board that is connected with the device by clicking on it.

How to select a processor in Arduino IDE?

how to select processor

Choose your processor. For certain boards, it is necessary to specify the processor of that particular board. Because depending on the models, certain Arduino boards may have different specifications of the processor embedded.

  • Open the Arduino IDE software.
  • Go to Tools menu and click on Processor option. It will show the list of Processors.
  • Select the correct processor that you have by clicking on it.

How to select Serial Port in Arduino IDE?

A computer has several ports that it uses to connect with interfacing devices. Usually, COM1 and COM2 ports are reserved. If you are not sure of the port that your Arduino is on, just hover over the menu and unplug your board. The COM listing that disappears is your board. Reconnect and select that particular COM port and you will be good to go.

serial port selection in the IDE

  • Open the Arduino IDE software.
  • Go to Tools menu and click on the Port option. You’ll be able to see all of the available ports.
  • This option will enable only after connecting the board.
  • Select the correct port that is connected with the board by clicking on it.

How to load an example code in Arduino IDE?

how to load example code

  • Open the Arduino IDE software.
  • Go to the File menu and click on Examples option than to Basics.
  • You can see the example programs. Now, Select the example program you want.
  • Click on the upload option. Now your board should perform according to the program that is uploaded.

How to compile code in Arduino IDE?

verify command button in IDE
Method 1
compile button in Arduino IDE toolbar
Method 2
  • Open the Arduino IDE software.
  • You can compile the code by clicking in the verify option in the drop-down menus.
  • When you click on the upload option, it will automatically compile your sketch.

verifying

How to execute code in Arduino IDE?

  • Open the Arduino IDE software.
  • Click on the File menu and select the New sketch option.
  • Write the code that you need to perform.
  • Click on the Verify option to compile the sketch.
  • Click on the Upload option and upload the sketch into the board. Now, the board will start functioning according to the code.

how to upload

What is the serial monitor in Arduino IDE?

Serial monitor

The serial monitor is simply an output screen, that can display the data sent by the Arduino/Genuino board via USB. You can send data to the board by entering the text and clicking on the send option. Moreover, you can choose the baud rate according to the baud rate used in the sketch. Connecting with the serial monitor will rest your board.

What is the serial plotter in Arduino IDE?

Serial plotter

A serial plotter is used to plot and navigate the graph using the data sent by the board. This feature helps a lot to understand the data variation in different conditions. For example, it helps you to understand the behavior of sensors in different situations. Additionally, it is an offline tool that allows you to visualize the data in the form of graphs. Above all, it is useful in code troubleshooting.

Features of Serial plotter:

  • It can plot multiple graphs
  • Notably, it works in offline
  • Auto-resize graph
  • Moreover, it can support negative value graphs
  • It can scroll automatically along the x-axis
  • Above all, You can assign different colors for every variable.

Here are the steps to access the serial plotter in the Arduino IDE.

  • First, open the Arduino IDE software.
  • Go to the Tools menu and select the Serial Plotter option. This will enable you to see the graph of data.

Serial plotter

What is the baud rate in Arduino IDE?

Baud rate is the number of signals transitions that occur in one second. Otherwise, it is defined as the rate at which highs and lows must be sampled to decode the signal. It includes,

  • Protocol overhead such as start/stop bits.
  • Moreover, It is application-specific data.

We can use different baud rates, they are 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200.

How to detect programming errors and troubleshoot them in the Arduino environment

Arduino Board not Recognized

Arduino-Error-Board-not-RecognizedSolution-for-Arduino-Error-Board-not-Recognized

It occurs when you use CH340g USB to serial converter instead of FTDI (FT232RL). Furthermore, The drivers for USB to Serial chips already come with the Arduino IDE setup file. Thus for using USB to Serial chips other than the standard one, you need to download the driver for that chip.

Invalid Device Signature Error

Invalid-Device-Signature-Arduino-Error

It occurs when the device signature on the board differs from the board that is selected on the IDE.

How to rectify this problem?

It is rectified by selecting the correct board.

The code doesn’t start on Power Reset

It occurs when the Arduino board doesn’t run the code that is uploaded into it even after the power is on.

How to rectify this problem?

Usually, when the Arduino is powered on the bootloader checks for a new sketch from the computer in the first few seconds. If there is no such thing happens, then it will start running the already existing sketch. If your code is sending serial data, the bootloader will not time out so the already existing code will not start to run.

In this case, give some delay to stop sending the serial data in the first few seconds. Therefore, it will allow the bootloader to run the pre-existing sketch.

Board not in Sync

This error is displayed as ; “avrdude: stk500_getsync(): not in sync: resp=0x00”. So that you can’t upload the code into your board.

How to rectify this problem?

  • Check whether the digital pins 0 and 1 of the Arduino board are not connected with the shields.
  • Additionally, make sure that the correct port and board are selected
  • Press the reset button and reupload the code.
  • Restart the Arduino IDE
  • At-last try to change the Arduino board and check.

Launch4j Error

Launch4j-Arduino-Error

It occurs due to the incompatibility of the JAVA Run-Time Environment (JRE) library.

How to rectify this problem?

It is rectified by switching off the Bluetooth or Wi-Fi connectivity of your PC.

Sketch Too Large

Sketch-Too-Large-Arduino-error

It occurs when the sketch is larger than the board’s flash memory. For Arduino Uno, the flash memory is 32 kb. In addition to that, 2Kb is used by the bootloader.  So your sketch must not exceed 32 kb.

How to rectify this problem?

It is corrected by using an integer data type instead of float. Thus use a const qualifier while declaring variables. Additionally, improve the algorithm to reduce the space complexity.

Sketch Uploads Successfully, but Nothing Happens

It occurs when the code is uploaded successfully. Yet the board doesn’t respond.

How to rectify this problem?

Specifically, make sure that the correct board is selected. However, it may occur due to the sketch’s memory size when it is larger than the capacity of the board. Hence it is rectified by reducing the sketch size.

Serial Port Already in Use

Arduino-Error-Serial-Port-Already-in-Use

It occurs when you try to upload the sketch into your Arduino board while the serial monitor is opened.

How to rectify this problem?

It is rectified by merely closing the serial monitor or plotter screen while uploading the code.

What are Compile errors?

It occurs during compilations of the sketch. Usually, it contains syntax errors. Thus it is displayed on the black screen below the editor screen.

compile error

How to find compile errors in your code?

It occurs due to incorrect punctuations, missing punctuations, misspellings, and wrong capitalizations. It happens when you use the variable that is not declared previously. Therefore, you should read the compile error indications keenly to rectify it. Some of the compile errors are,

  • Missing semicolons
  • Missing curly braces
  • Parentheses missing
  • Missing commas
  • Misspellings & wrong capitalizations
  • Missing variable initializations

Conclusion

This post has been a reasonably sufficient introduction to the Arduino IDE. We covered everything starting from the installation to dealing with standard errors. If you have any doubts or feel that some more specific features of the IDE need to be included in this post, let us know in the comments. In any case, any particular knowledge regarding the IDE will be included in the posts in our Arduino course whenever the need arises.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.