Page 46 - Programming the Photon Getting Started With the Internet of Things
P. 46

community.





        Uploading Your First Application


        Now that you have familiarized yourself with the Particle Build IDE, the next best thing to

        do is just write a simple application so you can understand a bit more how the process of
        flashing a program to your Photon board works. You will dive into more code later on, but
        just to give you an idea we will use one of the examples provided with the Particle Build

        IDE.

             First of all make sure your Photon board is connected to the Particle cloud. It should
        be blinking cyan, which indicates that it’s connected to the Particle cloud. In the Particle
        Build IDE navigate to the Examples header and look for a program called Blink An LED.
        Click the program, which should now be displayed on the main editor page. Alternatively

        you can quite easily create a new application and copy the following snippet of code into
        the active tab. Here is the code that we will use for our first example.


        //D7 LED Flash Example
        int LED = D7;


        void setup() {

            pinMode(LED, OUTPUT);
        }



        void loop() {
            digitalWrite(LED, HIGH);
            delay(1000);
            digitalWrite(LED, LOW);
            delay(1000);

        }

             The next step is to select your Photon to flash your code to. Click the Devices icon in
        the navigation bar on the left side, and you should see a list of connected devices to the

        Particle cloud. Next to your Photon name, select the star icon next to it to highlight that
        device as the active one to program. If you only have one device, this will automatically
        be selected and you can skip to the next step.

             Now that we have our code, click the Flash button, which will send our application

        firmware to the Photon wirelessly. If the flash was successful, the Photon LED will flash
        magenta and you should see the on-board blue LED blinking every second. Not the most
        amazing piece of programming wizardry, but nevertheless you now know the basics of
        using the Particle’s Build IDE environment.


             Under the application header you should see a button that says Fork This Example.
   41   42   43   44   45   46   47   48   49   50   51