
WRITING CODE – SOUND SCARY?
Once you’ve set up your Particle Photon, it’s time to start making it do your bidding. This means you must program it. While this may sound scary, it’s easy if you’re “borrowing” someone else’s code. I, and many others, freely put our programs out on the Internet so you can use them as a starting point. Personally, I recommend you begin all your early projects using something similar as a model.
Don’t reinvent the wheel, just realign it.
-Anthony j. d’angel
STEP-BY-STEP
So enough with the pep talk, let’s get started. What we’re going to do here is upload a very simple program to your Photon that blinks the blue LED on and off. While this program is very basic, you’ll use this same process to upload the “real” projects you build in the future … so this is a critical skill! To get started, you’ll want to make sure you already have a Particle account created (click here for the setup guide). You’ll also need to make sure your Photon is plugged in and connected to your network. Here’s a reference page that explains the different modes. Now here are the steps:
- Go to the Particle site and login https://www.particle.io . The login button is in the upper right-hand corner.
- Once in, click on the IDE button, also in the upper right. IDE stands for Integrated Development Environment, which is where you’ll do your coding. If you want a full overview of this tool, check out Particle’s official user guide.
- You’re now in the IDE, on the default entry page. This gives you the framework in which to start a new program. Here you’ll see the two required functions for all Photon programs: setup() and loop().
- If you have multiple Photons, now is the time you’d go to the Devices section and pick which one you want to program. For now, I’ll assume you’re doing this for the first time and only have one.
- Now is when you’ll copy & paste your borrowed code. (It’s at the bottom of this page.) For this, delete all 7 lines in the IDE code window. Then copy the sample code window below and paste into the code window.
- To save this new program, fill out the Title box, and click on the folder icon to your upper left. You’ll get a message near the bottom of the screen that says your code was saved successfully.
- Here is where the magic happens! To send your new program to the Photon, click on the lightning bolt at the lop-left menu. This will check to make sure your code doesn’t contain any errors, then begin the process of uploading your code. You’ll see the Photon’s lights blink different color for a few minutes, then eventually settle down. When it’s all over, you’ll see the slow fading in and out of the cyan LED. In addition, the blue LED will turn on and off every second.
- Give yourself a pat on the back! You now know how to program a Particle Photon!
Here’s the default screen described in Step 3


// Like an Arduino, the Particle Photon uses two main "functions". The first // is the setup() function, that does pretty much what it sounds like. The // second is a loop() that gets repeated over and over. void setup() { // D7 is the pin on the Particle Photon that has a built-in LED. Below, we're // going to set it as an output, rather than use it to read values from an // outside circuit pinMode(D7, OUTPUT); } void loop() { // Below we're going to set the D7 output voltage to HIGH, which will turn // on the built-in LED. digitalWrite(D7, HIGH); // The delay() function below will now wait for 1 second (or 1000 milliseconds) delay(1000); // Now we'll turn the LED off by setting the voltage to LOW digitalWrite(D7, LOW); // Now we'll wait another second. delay(1000); // This sequence will now be repeated over and over. }