- Find this text in the Blink code: "void setup( )"
- Notice the open curly bracket, {, that follows this text and the closed curly bracket, }, a few lines below.
- Notice the line of code “pinMode (LED_BUILTIN, OUTPUT);” is written between the curly brackets.
STEM Connections
Like all codes, the blink code is divided into different sections. The first section of this code begins with the text "void setup( )". Setup is a piece of code that gets the Arduino board ready to run the rest of the program. Fragments of code like this that perform defined tasks are called functions. There are many different functions in the Arduino programming language for many different defined tasks. The setup function will only run once each time the Arduino board is powered up or reset.
There are two curly brackets ({ and }) that come after the void setup( ) text. Everything between those brackets gives information to the setup function. The setup function ends after the closed curly bracket “ } “. Notice the setup function begins after the text "void setup( )" and ends after the text pinMode(LED_BUILTIN, OUTPUT);"
"LED_BUILTIN" refers to pin 13 on the Arduino Uno board because there is also an LED built into the board that is associated with pin 13.
“pinMode” is a function that sets up pins to be in INPUT or OUTPUT mode. The Arduino is looking for two values in the parentheses, what pin are you addressing, and what mode is it in. “(LED_BUILTIN, OUTPUT)” tells the Arduino that we will be using the built in LED associated with pin 13 as an output.
At the Thinkabit Lab, we explain that humans, not the computer, decide which pin controls a specific function.
- Explain that some Arduino software versions write “pinMode (13, OUTPUT);” and some write “pinMode(LED_BUILTIN, OUTPUT);” LED_BUILTIN is a variable name that is set to equal 13.
- Explain that if we wanted to use a different pin on the Arduino board, we would use that number here to set up that pin as an output.
If you are using the Thinkabit Lab Notebook:
Have students write their own comment in their notebook on page 14:
pinMode(LED_BUILTIN, OUTPUT); Pin 13 (LED_BUILTIN) is in output mode
The function ‘pinMode(LED_BUILTIN, OUTPUT)’ does not appear
-
In some versions of the Arduino software, the setup function contains the text “pinMode(13, OUTPUT);”. LED_BUILTIN is a variable name and it equals 13.