> For the complete documentation index, see [llms.txt](https://docs.launchboard.app/cxd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.launchboard.app/cxd/internet-of-things-project/references-for-wiring-and-coding/hello-world-app-for-photon.md).

# Hello World App for Photon

When learning a new coding language, many people first create what is called a "Hello World" program. Traditionally, this involves displaying the text "Hello World" on the screen. The purpose is to demonstrate that you can create a simple working program in the new coding language.

[![Hello World in BASIC](https://576155698-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDgX-RdB-DPZBPuXzJ1%2F-LDgX75Qrx69yS4tZ2_Z%2F-LDgXHfEQXpi6SoGpMYM%2Fhello-world.png?generation=1527608061890003\&alt=media)](https://en.wikipedia.org/wiki/BASIC)

Creating a working device with an electronics kit involves both building the physical device and programming it. So if your device doesn't work as expected, the reason could be that some of the parts are connected incorrectly – or the program might have a mistake – or it could be both.

So you will create a different kind of "Hello World" app for your Photon device: an app that doesn't require connecting any additional parts to the Photon, so you can first focus on getting some code to work.

The Photon has a built-in blue LED light that is connected to its D7 pin. This "Hello World" app will turn this blue LED on and off in a repeating pattern. This will be your first app before you start to connect additional parts to program more complex devices.

This app – like all apps that run on Photon devices – is coded in a programming language called **Wiring**. Here's an overview of the [Wiring programming language](https://docs.launchboard.app/cxd/internet-of-things-project/references-for-wiring-and-coding/wiring-programming-language.md).

## WHAT TO DO

1. Login to your [Particle Build](https://login.particle.io/build) account. If necessary, here's a [brief overview of navigating and using Particle Build](https://learn.sparkfun.com/tutorials/photon-development-guide/particle-build-online).
2. Create a new app titled: `hello-world`
3. Delete the placeholder code that Particle Build inserted for your new app (the empty `setup()` and `loop()` functions).
4. Copy and paste the code below into your new app. Save the app in Particle Build, and then load ("flash") the app onto your Photon device. During "flashing", Particle Build transfers the app to your device over Wi-Fi. The RGB light on your Photon blinks magenta as the new app is being flashed, and then the Photon restarts. *Be patient – sometimes it takes longer for your first app to flash because Particle may need to also update the firmware (OS) on your Photon device*.
5. After the Photon has reconnected to Wi-Fi, the new app will automatically start running. If everything worked correctly, the blue D7 LED on your Photon device should blink on and off repeatedly. It may not seem like much, but you've just taken your first step in coding with the Wiring language.
6. Once you get the app working, try modifying the code to change the LED blinking pattern. Flash your modified app to your Photon to see what your changes do. *Can you make the LED blink faster? Can you make it blink slower? Can you make it blink in a more complex pattern (maybe similar to Morse code)?*

## Code for Hello-World

```java
// HELLO WORLD app - introductory program that doesn't require connecting any parts

// GLOBAL VARIABLES - variables that will be used in multiple functions
// declare integer variable called "led" and assign it value of D7 (built-in LED)
int led = D7;

// SETUP function runs one time at start when device is powered on
void setup() {
    // set "led" pin to be an output
    pinMode(led, OUTPUT);
}

// LOOP function runs in repeating loop (after setup finishes)
void loop() {
    // turn on "led" pin (built-in blue LED light)
    digitalWrite(led, HIGH);

    // wait 1 second (1000 milliseconds)
    delay(1000);

    // turn off "led" pin
    digitalWrite(led, LOW);

    // wait 1 second
    delay(1000);

    // loop repeats itself again
}
```

A couple of things to note about the code:

* The lines that begin with two forward slashes are comments. Comments are just notes for people reading the code. The comments are ignored by the device when the app runs. Comments are **optional**, but it can be helpful to include comments to explain certain parts of the app.
* Integers are supposed to be whole numbers, but the Wiring language treats input and output pin names (D7, etc.) as "integer" variables.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.launchboard.app/cxd/internet-of-things-project/references-for-wiring-and-coding/hello-world-app-for-photon.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
