> For the complete documentation index, see [llms.txt](https://docs.idew.org/code-internet-of-things/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idew.org/code-internet-of-things/tutorials/hello-world-test/2.5-setup-function.md).

# B-5 Setup Function

Next you'll add a command in your app code to designate the LED pin as an output.

## Set Pin Mode for LED

A variety of inputs and outputs can be connected to the I/O pins on your Photon circuit board. Your app code needs to identify which I/O pins are being used and whether each of these pins will be used for an input or output. This is referred to as **setting the pin modes**.

You'll need to set the pin mode for the built-in LED that you'll be using. Add this code to your app by inserting it **within** the `setup()` function (between the curly braces):

```cpp
pinMode(LED, OUTPUT);
```

The `pinMode()` method requires two parameters inside its parentheses (in this order):

1. **The I/O pin number**, which can be the actual pin number (such as: `D7`, etc.) or a variable that stores a pin number. In this case, the variable `LED` is listed (which has a value equal to `D7`).
2. **The mode value**, which can be `INPUT`, `INPUT_PULLUP`, or `OUTPUT`. Your Photon uses this value to change the electrical behavior of the pin, so the pin can either receive signals from an input or send signals to an output. In this case, the mode was set to `OUTPUT` because your app will be sending "on" and "off" signals to the LED light.

At this point, your app code should look similar to this:

```cpp
int LED = D7;

void setup() {
    pinMode(LED, OUTPUT);
}

void loop() {

}
```

Notice that the `pinMode()` statement shown in the app code above is indented (using the tab key). This is a useful practice when adding code statements **within curly braces** because it helps make the code easier to read and understand – especially if your app contains many code statements nested within each other.

## Verify Your App Code

The Particle Build code editor does **NOT** check your code syntax as you type, so be sure to periodically verify your code to check for errors.

Verify your app code by clicking the **Verify** icon in the left navigation bar. (Particle Build will first save your code before verifying it.)

<div align="left"><img src="/files/-LJ10qTcnC_JJqBfpd6F" alt="Verify Icon"></div>

While Particle Build is verifying your code, it will display the message "Compiling code" in the status bar at the bottom of the code editor panel. When the verification process is complete, the status bar will indicate the results:

* If your code compiled without any errors, the status bar will display a **success message**.
* If your code contains an error, the status bar will display an **error message** with a description of the error and a link to the specific line number in your code where the error was detected (though sometimes the root cause of the error occurs on a previous line). You'll want to fix the error and then try verifying your code again.

{% hint style="warning" %}
**MULTIPLE ERRORS:**  Sometimes your app code might contain multiple errors. However, Particle Build will stop verifying the code at the first error that is detected. Once you fix that error and verify the code again, you might see a **new** error message for another error that occurs later in the code.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.idew.org/code-internet-of-things/tutorials/hello-world-test/2.5-setup-function.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
