0

https://www.arduino.cc/reference/en/

Language Reference

Arduino programming language can be divided in three main parts: functions, values (variables and constants), and structure.

functions

For controlling the Arduino board and performing computations.

variables

Arduino data types and constants.

structure

The elements of Arduino (C++) code.

I find it really confusing that they had to separate the structures but also call them functions in their descriptions. I kind of want to get a visualization or organization of the different language references present in Arduino, but this just confuses me. Are structures in the website also functions, and mainly syntax can be classified into functions and variables? Can someone present a organization of language references that doesn't involve terminologies being mixed up?

3
  • please provide an example of what confuses you
    – jsotola
    Mar 1 '21 at 4:27
  • perhaps it may clear your thoughts if you review C++ programming
    – jsotola
    Mar 1 '21 at 4:32
  • 1
    They're playing loose with terms. If you want a clearer understanding of C++ the C++ standard itself is a better reference.
    – timemage
    Mar 1 '21 at 9:25
2

What the website names "Structures" are code building-blocks for the programs you write. The main part there are conditional (if-else) and loop instructions (for, while) as well as mathematical operators. You use these constructs within your functions to control program flow or compute results. Functions, on the other hand, are sub-programs you can call to have certain tasks done. They might be pre-defined (such as the ones described on the language reference page) or written by yourself.

Now there are two exceptions to this rule, and maybe that's what's a bit confusing in the documentation: The functions setup() and loop(). These are functions, but make up the structure of your program. They are the main building blocks of an Arduino sketch, and that's probably why they're mentioned under "Structures".

2
  • Yes, this is the kind of explanation I am looking for. Someone who has a clear visual of their own with how the hierarchy of how the types of code are. It makes it really clear that under programs, we can put functions and under that we can put structures. Yes, the set up and loop is confusing but I would prefer categorizing it as functions because you can put structures inside. I'd like to ask, what references do you use for Arduino? You seem to have a good personal grasp on terminologies.
    – AndroidV11
    Mar 1 '21 at 12:53
  • Actually, I use exactly that page for things that are arduino-specific, and any other resources I find for any C++ issues I come across. The Arduino compiler is a full-featured C++ compiler, with almost all the features the normal GCC also has. The library functions are also all there, so if you need help for things like malloc or free just use your preferred search engine. (One exception here: STL support is not available out-of-the-box).
    – PMF
    Mar 1 '21 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.