C-2 Copy Hello World App
Next, you'll use the "Hello World" app as starter code for your "Smart Light" device app. You'll use this code to verify that you connected the LED correctly.
Log In to Particle Build
One person on your team should log in to Particle Build using your team's Particle account login.
Once you're logged in, you should see a new app template in the code editor. (If not, just click the "Create New App" button in the Code menu panel.)
Title New App
Enter smart-light
as your app's title.
Copy Hello World Code
You'll use the hello-world
app as starter code for your smart-light
app:
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.
Copy the "Hello World" code above.
In the code editor panel, select all the existing code in the
smart-light
app, and then replace it by pasting in the copied code.
Save your smart-light
app code by clicking the Save icon in the left navigation bar.
Modify App Code
You'll need to make a few changes to the app code:
Modify the comment block: Change
Hello World
toSmart Light Device
, and be sure your team info, teacher's name, and class period are correctly listed.Modify line 7 that declares the
LED
variable: Change the variable's value fromD7
toD0
(or whichever pin number your LED is connected to). This will allow your app to control your LED.
Flash App to Device
Be sure your Photon device is connected to Wi-Fi and Particle Cloud.
Flash your app code to your Photon device by clicking the Flash icon in the left navigation bar. (Particle Build will first save and verify your code before flashing it to your device.)
Once your Photon has downloaded the new app and restarted, the updated app will start running:
Confirm that the LED light that you connected to your Photon circuit board blinks on and off in a repeating pattern (with the light turning on for 1 second and then turning off for 1 second). The blue D7 light should be turned off.
Troubleshooting Issues
If the LED light that you connected is not blinking, then there is a mistake in your app code – or a mistake in your wiring connection – or a mistake in both.
If the blue D7 light is blinking, then check your app code to verify whether you changed the pin number assigned to the LED
variable. If necessary, revise your code, and flash the updated app to your device.
Otherwise, verify that the LED light's positive leg (the bent leg) is connected (via a jumper wire) to the same I/O pin number that is assigned to the LED
variable in your app code. If necessary, change either your wiring or your code, so the pin numbers match. If you revised your code, flash the updated app to your device.
If that still doesn't solve the issue, then double-check all your wiring by referring back to the connection instructions.
Last updated