> 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.4-global-variable.md).

# B-4 Global Variable

You'll add a variable in your app code to represent the built-in LED light.

## Add Global Variable for LED

Your "Hello World" app will make the Photon's built-in blue LED light turn on and off in a blinking pattern. This will be accomplished by sending separate "on" and "off" signals to the LED's pin.

Each I/O pin on the Photon circuit board is identified by a pin number (such as:  A0, A1, A2, D0, D1, D2, etc.). In this case, the Photon's built-in blue LED light is connected to pin D7 (via internal circuitry).

When coding a Photon device app, you will typically create a global variable to store a pin number for each input or output connected to your Photon. This will help make your code easier to understand because the variable names help identify each input or output.

You'll need to create a global variable to store the pin number of the built-in LED. Add this code statement to your app by inserting it (as a separate line of code) **before** the `setup()` function:

```cpp
int LED = D7;
```

{% hint style="success" %}
**HOW TO COPY CODE:**  When using this IoT code guidebook, you can copy a code block simply by clicking the **copy icon** displayed in the upper right of the code block.
{% endhint %}

This code statement does 3 things (in order):

1. **It declares a data type for the variable's value.**  In this case, `int` stands for integer (whole number). Photon pin numbers are always treated as `int` values (even though they have letters).
2. **It declares the variable's name.** In this case, the variable will be called `LED`. You get to decide what to name your variables. Choose names that will make sense to anyone reviewing your code.
3. **It assigns a value to the variable.**  In this case, the variable's value will be equal to `D7`, which is the pin number for the Photon's built-in LED light.

Notice that this code statement ends with a [semi-colon](http://wiring.org.co/reference/semicolon.html). Typically, each code statement in your app will end with a semi-colon. The semi-colon separates code statements, similar to how periods separate sentences in written English.

* The exceptions to ending with a semi-colon are certain statements (such as functions, conditionals, loops, etc.) that use [curly braces](http://www.wiring.org.co/reference/curlybraces.html) to enclose other code statements. However, within the curly braces, each code statement ends with a semi-colon.

Although you can actually list multiple code statements on the same line (because their semi-colons will separate them), each code statement is traditionally listed on its own separate line to make it easier to read the code.

## Save Your App Code

The Particle Build code editor does **NOT** autosave your work as you type, so be sure to periodically save your code.

Save your app code by clicking the **Save** icon in the left navigation bar.

<div align="left"><img src="/files/-LJ0pSQvLOewPan-6Z_m" alt="Save Icon"></div>

## Tips for Naming Variables

You get to decide what to name each variable in your app's code. However, here are a few rules and recommendations to help you name your variables:

#### RULES

* Each global variable must have a unique name.
* A variable's name **cannot** be one of the [keywords in the Wiring programming language](http://www.wiring.org.co/reference/).
* Variable names must be one word (no spaces allowed).
* Variable names can contain lowercase letters, uppercase letters, numbers, and certain special characters (such as underscores, etc.) – but the name **cannot** start with a number.

#### RECOMMENDATIONS

* Make each variable's name concise yet descriptive, so it will be easy to read and understand.
  * Example of variable name that's concise yet descriptive:  `button`
  * Example of variable name that's **too** concise:  `b`
  * Example of variable name that's **too** descriptive: `greenbuttonthatturnslighton`
* If your variable name combines multiple words, you can make the name easier to read by either using an underscore between words – or using "[camelCase](https://en.wikipedia.org/wiki/Camel_case)" (lowercase letters, but new words start with an uppercase letter).
  * Examples of variable names using underscores:  `red_light`, `motion_sensor`
  * Examples of variable names using camelCase:  `redLight`, `motionSensor`
* If you have multiple inputs or outputs of the same type (multiple LED lights, multiple buttons, etc.), add an adjective or number to their variable names to help identify them in your app code.
  * Examples of variable names with adjectives:  `redLED`, `blueLED`
  * Examples of variable names with numbers:  `button1`, `button2`&#x20;


---

# 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.4-global-variable.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.
