How to use the autocomplete feature with the Arduino IDE 2.0
Autocompletion when writing code is great. Not only does it save you time, but it gives you an understanding of how the programming language functions.
The Arduino IDE 2.0 comes equipped with this tool, to make your code-writing experience, a pleasant one. In this tutorial, we will go through some basics on how to use it.
You can easily download the editor from the Arduino Software page.
You can also follow the downloading and installing the Arduino IDE 2.0 tutorial for more detailed guide on how to install the editor.
Requirements
- Arduino IDE 2.0 installed.
The autocomplete feature
Whether you are writing code in C++, JavaScript, HTML, CSS or any other common languages, understanding the syntax and how to write functions is an absolute necessity. It is also an integral part of your skill progression, and the more you know about a language, the better a programmer you become.
Enter the autocompletion feature: a tool designed to increase your knowledge while writing code faster. It lives in the background, and is there to help!
Using the autocomplete feature
Using the autocomplete feature is easy, but let's take a look at how it actually works in action, and what the requirements are for it to properly function. We will now go through it an a step-by-step fashion.
- First, let's open the Arduino IDE v2. If it is the first time you are using the editor, it will just be a blank sketch.
- Now, to enable the autocompletion, we first need to select a board that we are going to use. We don't need to physically connect it to our computer to use the feature, but we need to select the type of board for it to work. This is done by navigating to Tools > Boards > {Core} > {Board}.
- With the board selected, we are all good to go. In the sketch, inside
void setup()
, start typing pin. You can now see a list of suggestions, wherepinMode(uint8_t pin, uint8_t mode)
comes up as a suggestion. By either clicking on the selection, or hitting "Enter", it will autocomplete it.
- Now, by clicking enter, it automatically marks the first parameter, which is designed for the
pin
that we want to define. If we now start writing LED, a suggestion forLED_BUILTIN
will appear. If we click enter, it will also autocomplete.
- Now if we mark the following parameter,
uint8_t mode
, delete it, and instead start writing OUT, we will see the suggestion forOUTPUT
appear, which we can also autocomplete.
- We have now written
pinMode(LED_BUILTIN, OUTPUT)
, with the help of the autocompletion tool!
Conclusion
The autocompletion tool can be a real time-saver, while also helping you develop an understanding of a programming language. In this tutorial, we demonstrated a very basic example of defining a pin as an output, but there are many more situations when it will come in handy!
More tutorials
Make sure you check out the other articles on the Arduino IDE 2.0
- Getting started with the Arduino IDE 2.0 (beta)
- Downloading and installing the Arduino IDE 2.0
- How to use the board manager with the Arduino IDE 2.0
- How to upload a sketch with the Arduino IDE 2.0
- How to install and use a library with the Arduino IDE 2.0
- How to use the Serial Monitor with the Arduino IDE 2.0