Page 47 - Programming the Photon Getting Started With the Internet of Things
P. 47
This allows you to create a copy from the example so you can edit and save your very own
version. This is useful when using snippets of code from the community. If you are
familiar with using Github, then this function works in the same way as forking a repo.
If you edit the code by changing the value of the delay() function from 1000 to 250,
which changes the ON and OFF timings of the on-board LED, you need to make sure you
hit the Verify button in the navigation menu on the left to confirm that there are no errors
when compiling the new firmware. You can then reflash the Photon with the new program,
and you should see that the LED is blinking much faster than before.
Account Information
In addition to what we have learned, there are a couple of other features you should
become familiar with in the Particle Build IDE, such as viewing important information
about your device, managing the Photon associated with your account, and unclaiming
your Photon if you want someone else to be able to use your Photon as well.
You can view the Photon’s ID by clicking the Devices icon on the left navigation bar
and then clicking the drop-down arrow next to the device. If you wish to unclaim your
device so someone else can use your board, click your Photon and in the drop-down box
click Remove Device. Once the device has been disassociated with your account, it is free
to be registered with another user’s Particle account.
When you start diving into using the cloud API, at some point you will need to know
what your device’s API key is. The API key is a unique number registered to your Photon
and should be kept secret. Under the Settings tab in your account, you can press the Reset
Token button to assign a new API key to your account. Don’t forget that if you have any
code with your API key already inputted, you will need to change this with the new API
key.
Using Libraries
When you want to use code or snippets of code across multiple applications, Particle
libraries make it easy for you to accomplish this. Particle libraries are easy to share, with
packages built by the community to assist in overcoming those common problems you
may encounter when creating your applications. The libraries are hosted on a Web-based
service called Github and then easily pulled into the Particle cloud IDE, where they can be
included in applications and shared with other users. You can include a library in your
application by finding a library that you want to use and clicking the Include In App
button, which will in turn add an #include statement to your application so you can use the
capabilities of that library.