To program the Arduino we need an Integrated Development Environment (IDE) called “Arduino”. This is an official and open source IDE introduced by Arduino.cc and it is used for writing, compiling and uploading the code to an Arduino. In this article I will discuss on the detailed introduction to Arduino IDE. Where I will uncover all the parts of its interface and how to use it. First we have to download and install this IDE. Here is the Download link – https://www.arduino.cc/en/main/software. Arduino IDE is available for Windows, MAC, Linux, Linux ARM (Raspberry PI). After download, install it and you are done. Now let’s explore this IDE.
Arduino buying links
|Amazon link for India||Amazon link for other countries|
Introduction to Arduino IDE
As mentioned earlier this is an open source IDE which makes the coding very easy that even a common person with no high technical knowledge can make codes for it. This IDE is available for Windows, MAC, Linux operating systems and it runs on the JAVA platform. It is based on “Processing” programming environment and comes with many inbuilt functions and command which makes the software very easy to use.
The code that we write in this IDE is known as sketch. After compiling an sketch it gives a Hex file which we can upload to the Arduino. The code is written in the C or C++ language. Its user interface has a navigation menu bar on the top, text editor in which we write the code and a output pane where compilation logs are shown.
At the top name of the sketch and version of Arduino is displayed. Then we have the Menu bar just below that. In the menu bar we have five options. Let’s see them one by one.
In this menu we have these options.
|New||It is used to open a new sketch|
|Open||To open existing sketch|
|Open Recent||To open recent sketches|
|Sketchbook||To open the entire sketches|
|Example||To open example codes|
|Close||To close the window|
|Save||To save the sketch|
|Save As||To save the same sketch with different name|
|Page Setup||To setup the page with portrait or landscape|
|To print the text editor|
|Preferences||It is used to set the page preferences, the sketchbook location, compilation options etc..|
|Quit||To close all active windows|
This section is used for editing the code text such as copy, paste, select all, find, copy as HTML etc.
This is used for compiling, uploading, exporting the compiled code as binary file, to see the sketch folder.
This is mainly used to select the Arduino type and port, burning bootloader to the new microcontroller. There are also some other option are available which are serial monitor and serial plotter. More of that is explained later.
This is help desk of the software.
Short-cut Buttons In Arduino IDE
There are some important shortcut buttons are also available just under the menu bar. Which are verify (compile), upload, new, open, save and serial monitor.
Button with right check mark is for verify the code we have just written. If we written the code without any logical or syntax or any errors, it will compile successfully. Just in case we have written something wrong, it will give an error message in output pane about what and where the error is. Shortcut key for verify is “CTRL+R”.
This shortcut button showing right sided arrow is called upload and used to upload the code into the microcontroller of Arduino. Shortcut key for this is “CTRL+U”.
This shortcut button showing dotted paper is used to open a new sketch. Shortcut key to open a new sketch is “CTRL+N”.
The button with arrow up is used open an existing sketch. Shortcut key to open an existing sketch is “CTRL+O”.
The button with arrow down is used to save the sketch. Shortcut key to save a sketch is “CTRL+S”.
As we press this button a separate window will pop up which will show the data that that is being transmitted and received from an Arduino board. Shortcut key for open serial monitor is “CTRL+SHIFT+M”
To start sending or receiving serial data we have to start serial communication in the code. Let’s see how we can start serial communication in Arduino.
Here is the code and output serial data. First we have initiated the serial communication by using Serial.begin command and giving it the baud rate. Baud rate is the rate at which data is transmitted or received. We can choose other baud rates also which are valid and the other device is compatible with.
Then we have printed the two string using Serial.println() command and given one second delay between them. This printing process will run infinitely till Arduino is powered because we have put the code in “void loop” function.
Serial plotter in Arduino
There is another serial function and we call it “serial plotter”. Basically it is same as serial monitor but it shows the serial data in the form of graph except string data. Suppose we are working with some kind of heat sensor which output a data according to heat. So, serial plotter will show us heat in the graphically. We can open serial plotter window by using shortcut key “CTRL+SHIFT+L”.
Here in the code, “i” is declared integer as globally. It means that we can use this everywhere in the code. Then we started serial communication at 9600 baud rate. Using the for loop value of “i” goes up to 254 from 0. Then we print “i” serially. This basically means that we are printing the value of “i”. As you can see that we have the graph of integer “i” printed on serial plotter window. Here x-axis depends on the number and y-axis depends upon the highest value of serial data available.
Selecting the board type and port in Arduino
To upload the code on Arduino or serial communication or serial plotting we need to choose the right board and port of board. These options will be available under “Tools” option and put the mouse arrow on “Board”. It will open a window like figure shown below.
From here you can choose the board you have connected form computer. And then go to port option. Here we will be selecting the port of your operating system from which your board is connected. It will look something like this.
In my case my Arduino UNO is connected to my COM11 port.
After selecting right board and port you can upload code to the board, see and plot the serial data. During the code is uploading, the RX ant TX led on board should blink.
Including the libraries in Arduino code
In programming world libraries are so important. It consists the instruction set and predefined function that we can run without writing it repeatedly. It adds extra functionality to any sketch that we are writing by just including it. In Arduino we can include any library by using a command “#include<library_name.h>” or by going to Sketch>Include Library>Select any Library.
You can include only those libraries which are available in your Ardiuno’s “Library” folder. If any library is not present in your library folder then you can add it by downloading it from internet. Or you can do it within your Arduino IDE by going to Tool>Manage Library and search the library name and click install. Shortcut for library manager is “CTRL+SHIFT+I”.