In this tutorial, I show you how to:
– Configure and manipulate this application, so you can program various development boards;
– Import new library (in 2 different ways).
Arduino IDE is needed to easily program the Arduino board. The Arduino IDE compilers (converts) the code that you write into machine instructions , so that the Arduino can understand.
You need to install Arduino IDE before proceeding.
Instalation link: https://www.arduino.cc/en/Main/Software
Configuring the Arduino IDE
Step 1: Start from open Arduino IDE. If you don’t have it installed yet you can download the last version from here: https://www.arduino.cc/en/Main/Donate
Step 2: Select your board on “Tools -> Board -> Board Manager…”.
If the board you are using is not in the list then you need to install your board. For example, the first time you use ESP8266 based boards on Arduino IDE you need to add them to the boards manager. In “File -> Preferences” paste this link: http://arduino.esp8266.com/stable/package_esp8266com_index.json and click “OK”.
Step 3: Then you need to install them on “Tools -> Board -> Board Manager…”. Search by “esp8266” and install the last version of the boards.
Step 4: Select your board, in this case is “NodeMCU 1.0 (ESP-12E Module)” board, on Tools -> Board ->…
Step 5: To test the operation of the board, I advise you to import an example of the Arduino. We use the example of blinking the board LED (built-in LED). Click on “File -> Examples -> 01.Basics -> Blink”, and this opens a new IDE window with the selected example.
There are several Arduino examples, which can be a good starting point for beginner programmers. For example, digital and analog pin control, serial ports utilization, timers, sensors control, etc…
Step 6: Connect your Arduino to your PC using micro-usb to usb cable and upload the code, pressing upload button.
If the upload is successful, then no error messages appear and LED blink.
Libraries are files written in C or C ++ with extension “.c or .cpp”, which facilitate the use of shields and modules (e.g. the ability to control an LED matrix, control LCDs, etc.) . With these it is possible to use dedicated code made by other people, using only high level functions.
To use an existing library in a sketch simply Click on Sketch -> Include Library -> Manage Libraries, and install from the libraries available (2nd picture below). Now, you need insert an “#include” line at the top of the sketch for each header file (.h) in the import library’s folder. These code lines make the public functions and constants defined by the included library.
If you have a library in “.zip” format, you can import this to your sketch. Click on Sketch -> Include Library -> Add .ZIP Library, and choose your .zip library. Usually this is the way to import libraries from GitHub repository.
Do not forget to do “#include ‘your library'” in your sketch
Insert line numbers and Code Folding in your sketch
I like use line numbers in my sketch, because it is easier to navigate over long sketch. If you want to do it, click on “File -> Preferences” and enable “Display line numbers”.
You can hide and show code functions, for this you need enable Code Folding in preferences:
As you can see in the image above, the functions have the option to hide or show.