The Arduino framework

The Arduino development framework. How it works, how to install and configure it

If you need additional specific information about this topic or if you want to look it personally please write an email

Arduino is one of the most famous development environment used to build source codes, called Sketches, that you can upload on any Arduino card to run a workflow to manage the input and output PINs installed on the board.

In the past few years Arduino has released different versions of the original board and all of these versions can be uploaded and managed with the basic version of the development framework.

I don't know the legal reason for this decision but Arduino has been built in Italy (so in Europe) and in Italy the official name is no longer "Arduino" but "Genuino" while in US (where the board has been exported) the Arduino name remained.
In Theory I should, then call it Genuino but I prefere the real name and this is what I will use.

Well, first of all open the arduino.cc web page. At the time of this article the page is more or less the following one:

Arduino Web Site

The official Arduino web site is very interesting and can stimulate your fantasy with thousand of good ideas (surely more than the ones available in my poor website). From the official web site you can download the latest version of the development environment selecting the "software" menu. From this page you can load the framework setup.

Download and install it on your desktop.

For different reasons that you will understand late in this article, I strongly suggest you to use the default path to install the core framework (I mean the parser and the compiler)..
Different story is for the sketches folder (the folder where you store your source codes). In fact, based on Arduino convention, source codes must be originated all in the same folder. The name of the folder can vary and can be configured in the configuration page of the framework.

To do this, run the framework and select from the file menu the "preferences" option.

Preferences menu of the arduino dev environment

At the top of the form you will be able to write the folder name of your sketch folder. From now on that folder will be used to open and store subfolders containing your projects.

Any Arduino sketch has a .ino extension and it is very important to remember that it should be contained in a folder name with the same name of the .ino file name. So, for example, if the name of the project is "VittorioTest" then, in the sketch folder, you will have a folder named "VittorioTest" and in this folder you will have a file named "VittorioTest.ino" containing the two main functions composing an Arduino sketch (The Setup function and the loop one).

If the file is composed by more than one file, all those files will be in the same folder or in subfolder referenced in the main file.

You can also build external functions in c or cpp file and build everithing in a single project. In order to do this you can create the .h and .cpp (or .c) file and include the .h file in the main .ino file. This at parsing time will directly load the cpp file and will compile it.

This technique, allows you also to build real makefiles and to compile complex projects from a separate environment (It is just c or cpp so you don't need the Arduino framework at any cost).
An interesting example could be the Marlin firmware, that is a very big project, composed of many files in the Marlin folder which is released also with a makefile that can be used to compile it autonomously.

picture of the marlin folder

In the "tools" menu of the Arduino development environment, you can configure the board that you want to use to run your code (and all other parameters like the com port, the parity etc.). Obviously, every board has certain components and pins so, not all boards can be used from the same source code and you could need changes to migrate the same software from a board to another one.

Arduino is a board that you can use to build complete IoT components or complex projects (3d printers, robots etc. etc.etc). In order to do this, many time you will be requested to connect Arduino with sensors, objects, cards and other external components. In some cases you will be requested to use features already available on the arduino card (like, for example, the curie imu installed on board of the Arduino 101 module). All those components can be driven using external libraries. This means that Arduino is a platform stricly linked to libraries. In order to configure an Arduino Library I already prepeared the following tutorial to let you understand how to configure and use a library.
The concept is very easy. Same Sketch folder, a new folder called libraries with all subfolder in it. One for each library. The name of the folder must be the same name of the .h file to include in the project. The library must be included in the .ino file of the main project and this will allow the main sketch to call all functions available in the library.

Once installed the main framework you can decide if to continue to use the basic development environment or if to use something more "User Friendly" available on the market. The tool I selected personally (the one I use) is called "Visual Micro". Visual Micro is an addOn that you can install in Microsoft VS2013 community edition to manage Arduino Sketches. Visual Studio Community edition is an interesting version of the Microsoft development environment. It allows, in fact, 3rd party companies to build plug-In or Add-on to interact with the Visual Studio Environment and create a sort of integration between their application and the Visual Studio one.

This is exactly what VisualMicro did. An addon able to connect Arduino framework and visual studion obtaining a single development environmnet.

Once installed the PlugIn, run Visual studio. You will see different new menus available to manage Arduino sketches. All of these menu are directly inside the visual studio development environment

Visual Micro menu in Visual Studio

This menu, for example, is the main configuration menu for the plugin. It is important to note that you are configuring the plugin to be able to reach the real Arduino framework (that must be installed in any case) and to create a sort of "bridge" between Visual Studio and the Arduino Framework.
All the Visual Studio Menus are updated with plug-In functions like the one to compile and load the Arduino sketches.

When you select to compile the Arduino sketches:

Build menu of Visual Micro

The Compiler used is not the core VS compiler but the Arduino one. The one installed under the "c:\Arduino" folder (This is also the reason why, originally, I suggested to not change the Arduino framework base folder). In this case you used features coming from Arduino framework and features, like the intellisense, coming from the Visual Studio Framework and this makes your effort more productive and supports you to speed up your development.
PlatformIO is another interesting platform you can use to build code for Arduino, compile and upload on different boards. The difference, in this case is that PlatformIO is an opensource platform running on different development environmnents while Visual Studio is limited to Micorosft platform only (even if the "Visual Studio Code" editor is now multiplatform as well).

Leave a Comment