- Why isn't there a search function in the forum? Under Project Guidance there are over 3300 pages of titles.
- I loaded Blink and the line 'pinMode(LED_BUILTIN, OUTPUT);' had no predecessor such as 'int LED_BUILTIN=13'. Where was the Upload function told to load a header file? Why can't I see the header file? Okay, maybe I'm misusing the term 'header file', but I'm sure you get the idea. Basically, where/how was pin 13 associated with LED_BUILTIN?
- Where can I get a manual or similar on the IDE?
- Why isn't there a search function in the forum?
You mean like the one up there on the right?
There is a search capability. The thing like a magnifying glass at the top of the page.
All of the source code for Arduino programs is available within the Arduino IDE - though it can be a bit difficult to find things.
The Resources link at the top of the page is the "manual"
2. I loaded Blink and the line 'pinMode(LED_BUILTIN, OUTPUT);' had no predecessor such as 'int LED_BUILTIN=13'. Where was the Upload function told to load a header file?
The Arduino IDE automatically adds the following line to the primary .ino file in every sketch:
That was done with the intention to make the Arduino IDE more beginner friendly by making the Arduino core library's functions automatically available to every sketch.
Why can't I see the header file?
The first thing you need to understand is that each architecture has its own core library due to the low level code behind the Arduino core library functions being architecture-specific. This means that the location of the header file can depend on which board you have selected from the Tools > Board menu. An Uno has a different core library than a Zero because they are different architectures (AVR vs SAMD). The Uno and Mega use the same core library because they're both AVR architecture.
You can find the location of the core library for the board you're using by turning on File > Preferences > Show verbose output during: compilation and then examining the contents of the black console window at the bottom of the Arduino IDE window after a compilation. Note that these files are often stored under a system folder that your OS may hide by default. There a trick that makes it a bit easier and quicker to find it:
- File > Examples > SPI > BarometricPressureSensor
- Sketch > Show Sketch Folder
- Move up folder levels until you reach the one that contains boards.txt
You will now find Arduino.h and the rest of the core library under the cores folder. You can open them with any text editor.
Basically, where/how was pin 13 associated with LED_BUILTIN?
As an example, say you have Tools > Board > Arduino/Genuino Uno selected. This board is part of the Arduino AVR Boards hardware package. If you open the Arduino.h file from that core you will see this line:
Each board within a hardware package may have a different number of pins or mapping of the chip pins to Arduino pin numbers. For this reason, the Arduino IDE uses a "variants" system. Each board has a definition in the boards.txt file. One of the properties of that definition is build.variant. For Arduino/Genuino Uno it looks like this:
This is used in the compilation recipe to customize the include path for that board. If you check the verbose compilation output you might see flags like this in the compilation command lines:
The "standard" part of that path is determined by the build.variant property in boards.txt. So this adds the standard variant's folder to the include path. If you check in that variant folder, you'll find a file named pins_arduino.h, which contains the pin mappings for the Uno. One of the lines in that file:
#define LED_BUILTIN 13
By using LED_BUILTIN, the code will automatically adapt no matter which board you're using, as long as the board that has an onboard LED and a definition of the LED_BUILTIN macro in its variant file. For example, if you were compiling for the MKR1000, it would still work even though the LED is on pin 6 instead of 13:
#define PIN_LED (6u) #define LED_BUILTIN PIN_LED
Making things simple for a beginner results in some complexity under the hood.
Stop multiple posting !
Do not post into sections that are for other purposes completely different to your problem.
Your post in "project HUB" deleted !
It's the second time @edjburke did that. It's extremely annoying to see them, not only cross post, but also say in that cross post:
No answers were given for questions 2 and 3.
after I provided an extremely detailed answer to question 2 and the other questions were answered sufficiently.
Given benefit of doubt as a newbie rather than a stick.
But OP had better catch up on forum rules as the stick could well be next.