ArduinoIDE - Tips and Tricks

Compared to other development environments, ArdunioIDE is very simple. There are not many things that can be set or adjusted. This has the advantage that beginners or "non-specialists" are not overwhelmed by the variety of settings and there is not so much to do wrong when programming and transferring.

Nevertheless, it is worth taking a closer look at a few settings, as some of them can make working with the ArduinoIDE even easier.

I present a few tips and tricks in the following article.


Requirements

Before you can start with the Arduino IDE, you must of course install it first. This is shown as an example in the article Install programs - an example described.

Required material:
-no-

Required tool:
-no-


Default settings

A few of the functions of the Arduino IDE are described below. For example, a few useful functions are hidden in the "Preferences" menu.

You can open the preferences window by clicking on "File" and then on "Preferences".

In my opinion, the settings shown above are very useful.

  • The setting of "Editor language" and "Editor text size" depends on your own preferences.
  • Under "Detailed output during" you should activate the checkbox for "Compilation" and "Upload". This is the only way to obtain detailed information. This may make troubleshooting much easier.
  • As a result, you should also set the "Compiler warnings" to "All". This is because compiler warnings also help you to avoid programming or runtime errors.
  • You should activate "Show line numbers". This means that the line numbers are numbered consecutively in the code editor. This makes it easier to find your way around larger software projects.
  • "Activate code folding" has the effect that code parts - which are framed by a bracket - can be hidden. To do this, click on the small plus symbol next to declared functions in the code editor.
  • "Check code after upload" should be activated. Then, after programming the microcontroller, the code programmed on it is downloaded again and compared with the previously programmed code. This ensures that no transmission errors have occurred during the programming process.
  • If you activate the "Use external editor" function, this deactivates the editor integrated in the Arduino IDE. The Arduino IDE can then only be used as a programming tool.
  • If activated, "Aggressively cache compiled core" ensures that your code is only recompiled if you have also made changes to your code. This means that repeated programming processes run much faster because the code is not recompiled each time.
  • "Check for updates at startup" causes the Arduino IDE to check whether a new version is available each time it is started.
  • "Update sketches to the new file extension when saving (.pde -> .ino)" is self-explanatory and should be activated.
  • You should activate "Save when checking and uploading". This causes your code to be saved before each programming or compiling process. This has the advantage that your code is saved and in the event of a crash - during compilation - the Arduino IDE is not lost.

Set target board

Before you can transfer the code you have created to your Arduino board, you must set up the appropriate board. You can do this under "Tools" and "Board". If you are using an "Arduino Nano", for example, you must also select an "Arduino Nano" there.

Here you must set the board you are using.

Set target board options

For some target boards, other options can be set in addition to the target board itself. These can be found under "Tools" and then below the "Board" option. With an "Arduino Pro or Pro Mini", for example, the processor used can be set.

Set many more options for a "Generic ESP8266 Module".
Before you transfer your programmed code to your board, you should always check that the options set there are correct.

Setting options of an "Arduino Pro or Pro Mini".
Setting options of a "Generic ESP8266 Module".

Set programming port

Arduino boards are normally programmed via the serial interface. To do this, you must set the correct port under "Tools" and "Port" under which your Arduino board is connected to the computer.
It may happen that your computer lists several com ports. In this case, if you want to find out which com port belongs to your Arduino, you should disconnect the Arduino from the computer, then check the list of com ports, then reconnect the Arduino to the computer and, after the Arduino has been recognized, select the com port that has now been added to the list of com ports.


What do setup() and loop() do?

Every program created with the ArduinoIDE contains the two functions "setup()" and "loop()".
These two functions can be used deliberately during programming.

The "setup()" function is only executed once after the microcontroller is started. This makes it perfect for initializing sensors or the like.

The "loop()" function is then executed. Each time the function is executed, it is called again. The "loop()" function therefore calls the functions it contains in an endless loop.


Using the serial monitor for debugging

The "Serial monitor" can be started via the "Tools->Serial monitor" menu.
This can be used very well to send values to the computer during the development process. It can also be used to send commands to the connected Arduino.

How you can use the serial interface is described in more detail in the following article.
Arduino - The serial interface


Using the serial plotter to visualize data

In addition to the serial monitor, you can also use the serial plotter to send data from the Arduino board to the PC. This can be found under "Tools" and "Serial plotter". The "Serial plotter" displays numerical values as a time curve. This also allows curves or numerical values to be displayed over a longer period of time.

How you can use the serial plotter is described in more detail in the following article.
Arduino - The serial interface


Integrate new libraries

The great thing about the other Arduino IDE is that you can easily integrate and use libraries from other developers. For example, you can already use ready-made libraries for many sensors and actuators.

The integration of libraries is described in this article: ArduinoIDE - Installing a library


Bring structure to the program using tabs and swapped files

As soon as you have programmed somewhat larger projects and therefore written more code, it can quickly become confusing. That's why the Ardunio IDE offers the option of separating code parts into other files or tabs.

To create a new file or tab, click on the small arrow at the top right of the Ardunio IDE and then on "New tab".
Now you have to enter a name for the new file/tab in the lower area.
After you have entered the name of the new tab/file and confirmed with "OK", the new tab is displayed in the Arduino IDE.
You can now define functions in the new tab...
...and use them in all other tabs.

Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

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