ArduinoIDE – Tips and Tricks

The ArdunioIDE is very simple compared to other development environments. There are not many things you can turn on or off. This has the advantage that beginners are not overwhelmed by the variety of settings and you can not do so much wrong in the programming and transmission of your code.

Still, it’s worth taking a closer look at some settings, as some of them can further simplify working with the ArduinoIDE.

A few tips and tricks on this are presented in the following article.

Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂


Requirements

Of course, before you can start with the Arduino IDE you have to install it first. This is described as an example in the article Installing programs – an example.

Required material:
-no-

Required tools:
-no-


Preferences

Below are a few of the features of the Arduino IDE. For example, some useful functions are hidden in the Preferences menu.

The Preferences window opens by clicking on “File” and then on “Preferences”.

The settings shown above are very useful in my opinion.

  • The setting of “Editor Language” and “Editor Text Size” depends on your own feelings.
  • For “Detailed output during” you should check the “Compile” and “Upload” checkboxes. This is the only way to obtain detailed information. This facilitates the troubleshooting enormously.
  • As a result, you should also set the “Compiler Warnings” to “All”. Because even compiler warnings help you to avoid programming or runtime errors.
  • You should also activate “Show line numbers”. This will number the line numbers in the Code Editor. This facilitates orientation in larger software projects.
  • “Enable code convolution” causes pieces of code – framed by a bracket – to be hidden. To do this, click on the small plus icon next to declared functions in the Code Editor.
  • “Check code after upload” should be enabled. Then after programming the microcontroller, the code programmed on it will be downloaded again and compared with the previously programmed code. This ensures that no transmission error has occurred during the programming process.
  • If you activate the “Use external editor” function, this deactivates the editor integrated in the ArduinoIDE. The Arduino IDE is then only to be used as a programming tool.
  • “Aggressively cache compiled core” – if activated – ensures that your code will only be recompiled if you have made changes to your code. As a result, repeated programming operations are much faster because the code is not recompiled each time.
  • “Check for updates at startup” causes the Arduino IDE to check for a new version each time it starts up.
  • “Updating sketches when saving to the new file extension (.pde -> .ino)” is self-explanatory and should be enabled.
  • You should aso activate “Save when checking and uploading”. This will cause your code to be saved before any programming or compilation process. This has the advantage that your code is secured and in case of a crash – during compilation – the Arduino IDE is not lost.

Set target board

Before you can transfer the code you created to your Arduino board, you need to set the appropriate board. This can be set under “Tools” and “Board”. For example, if you use an “Arduino Nano” you have to select an “Arduino Nano” there as well.

Here you have to set the used board.

Set target board options

For some target boards, you can also set other options besides the target board itself. These can be found under “Tools” and then below the option “Board”. With an “Arduino Pro or Pro Mini”, for example, the processor used can be adjusted.

For a “Generic ESP8266 Module” many more options can be set.
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 need to set under “Tools” and “Port” the correct port under which your Arduino board is connected to the computer.
It may happen that your computer lists several com ports there. If you want to find out in this case which Com-Port belongs to your Arduino you should disconnect the Ardunio from the computer, then check the list of Com ports, then reconnect the Arduino to the computer and after the Arduino has been detected, the connected Com-port has now been added to the Com ports list.


What do setup() and loop() do?

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

The function “setup()” is executed only once after the start of the microcontroller. This makes it perfect for initializing into your sensors or similar.

Then the function “loop()” is executed. Each time the function is executed, it is called again. The function “loop()” calls in an infinite loop the functions contained in it.


Use the serial monitor for debugging

The “Serial Monitor” can be started via the menu “Tools-> Serial Monitor”.
This can be used very well to send values to the computer during the development process. In addition, commands can also be sent to the connected Arduino.

How you can use the serial interface is described in detail in the following article.
Ardunio – The serial interface


Use the serial plotter to visualize data

In addition to the serial monitor, you can also use the serial plotter to let you send data from the Arduino board to the PC. This can be found under “Tools” and “Serial Plotter”. In the “Serial Plotter” numerical values are displayed as a time course. This way curves and numerical values can be displayed over a longer period of time.

How to use the serial plotter is described in the following article.
Ardunio – Die serielle Schnittstelle


Include new libraries

Another great thing about the Arduino IDE is that you can easily integrate and use libraries from other developers. For example many, already available ready-made libraries make it easy to communicate with many sensors and actuators.

The installation of libraries is described in this article: ArduinoIDE – Installing a Library


Bring structure into the program using tabs and paged files

As soon as you have programmed some larger projects and therefore written more code, it can quickly get confusing. Therefore, the Ardunio IDE offers the possibility to split code parts into other files or tabs.

To create a new file or tab you have to click on the small arrow in the Ardunio-IDE and then on “New Tab”.
Now you have to specify a name for the new file/tab in the lower area.
After entering the name of the new tab/file and confirming with “OK”, the new tab will be displayed in the Arduino IDE.
So you can now define functions in the new tab …
… and use them in all other tabs.

I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

Fab

P.S. 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 appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com

Leave a Reply

Your email address will not be published. Required fields are marked *