Lesson 2 - Software setup





Arduino IDE

Arduino provides a free open-source programming software, called Arduino IDE. This software allows users to write codes, compile and upload it to their boards. As well as this, developers can use pre-written libraries and create their own. Arduino IDE is a programming software widely used to program other third party compatible boards, including clones and counterfeits.


Installing the Arduino IDE







1. To begin with, go to https://www.arduino.cc/en/Main/Software

2. Select the operating system you wish to install the software on.

3. Arduino offers the software as a free open source product but accepts donations and contributions of your choice, prior to installation, to support the development of the software.

4. Run the downloaded file.

5. Grant administrator permission.

6. Agree to the software license agreement.

7. Tick the appropriate boxes of what you wish to install. You will need the Arduino Software and the USB drivers as a minimum.

8. Choose a desired folder to complete the installation.

9. When prompted, ensure you download the Arduino USB Driver.

10. Wait for the software to complete installation and then load up the Arduino IDE.


Software Infrastructure





When the Arduino IDE loads up, a new blank sketch will be open. There are a few key areas of the software which are required when coding, verifying and uploading a program. From the menu bar at the top, you can access the software settings and adjust certain settings to your own preference.


Arduino IDE C++ Coding Key Points







The programming language used on the Arduino IDE is C+=, which is a common coding language across many platforms. There are a few key points you must be aware of before we begin programming on the software.


1. Global Scope - The global scope is an area which is not within a function. This is used to include libraries, assign variable names to analog/digital pins and choose data types. Anything declared in this area is called a global variable and can be read in every function within the program.


2. Void Setup - Every Arduino sketch has this function which runs an initial set of code to setup the program and only runs once at the start, until the board is restarted.


3. Void Loop - Every Arduino sketch has this function which contains the main instructions. This function repeats in a loop until the board is disconnected.


4. Serial Monitor - The serial monitor is a convenient feature which is the 'tether' between the Arduino and the computer. In this window, you can view what the Arduino is currently doing, as well as manually control the board using your computer. This is handy for debugging and we will be using this feature throughout our programming.


5. Comments - A good programmer regularly adds comments to their program to explain what is happening at a certain instruction. To add comments within your code simply type '//' followed by your comment. The text will be greyed out and not included within the code.


6. The 'Forgotten' Semi-Colon - When programming using C++, it is important to remember that at the end of each instruction line, you end with a semi-colon before proceeding, This can often be forgotten and causes compiler errors.





Configuring an Arduino with the Arduino IDE

So that we can upload programs to our Arduino boards, there are some steps we must take. These are to configure the software to the correct serial port, where the board is connected and so the program can be compiled and uploaded.


1. First, load up the program which you will be uploaded to the Arduino Microcontroller

2. Using the correct cable, wire up the board to the device you are programming on.

3. From the menu bar of the IDE, select Tools > Port > Choose the name of your board connected.

4. Once you have selected this, the IDE will be ready to verify, compile and upload your program to the board.


Note: These steps must be completed each time the Arduino IDE is loaded up, when the Arduino is disconnected from the PC or each time the program is ready to be uploaded to the board.



By Zaqyas Mahmood, Electronics Engineer