This is a quick guide for how to work with your photon. This page also contains links to other resources that you will find helpful.
The photon is based on the Arduino platform, but with a few variations. Most of the code you use for Arduino you can also use for the Photon.
Particle has it's own online system (IDE) for you to create code and upload it to your photon. It's available through your Particle login.
In this IDE you can create code, save it, access libraries of existing code, and send code to your photon (this is called 'flashing'). Once you're in build, in the main frame you will see a standard form template for code. You will see two 'functions': setup and loop.
void setup() { // the code inside here runs once only, // when the photon is first turned on }
This function is used for the initial set up each time your photon turns on. It runs only once, right after the photon is turned on.
void loop() { // the code in here runs after setup() is complete and will // run over and over, until the photon is turned off }
This function is where the main work happens. Loop() does just that, loop over and over again. The code that you put in here will run and then keep repeating as long as the photon is turned on. It's where most of the work happens.
For example, if you want to take a temperature reading every 20 minutes and then send it to the database, you would create code inside loop() that:
Then loop() would make this code repeat until the photon is turned off.
The first place to look for code or for help is through google. Let's face it, it's impossible to know everything. Plus things in this field change so rapidly, that you can't keep up with everything. In this community, we share and help each other out through bulletin boards like StackOverflow. It's the way things work and it works well.
Search either particle photon yoursensor or arduino yoursensor. Both will give you useful examples.
The next place to look is in the Particle library. In particle build, on the left side there is an icon that looks like a ribbon (similar to the one above). Clicking on that allows you to search the library for sample code. A few tips:
Now that you have written your code, you have to flash (send) your code to the photon. Here's the process you should follow:
Save your code by clicking the folder icon on the left side of build.
Check or verify your code by clicking the tick icon on the left side of build. This runs through your code to see if there are any errors that will prevent your code from running.
Target your device by clicking the icon that looks like a gun sight, the select your photon. Click just to the left of your photon and a yellow star should appear.
Check or verify your code by clicking the tick icon on the left side of build. This runs through your code to see if there are any errors that will prevent your code from running.
Particularly see the firmware and and cloud functions sections. Click on the + symbol next to these headings to see more detail.
This is a great resource. People who use particle products ask questions about everything and get answers from all over the place. You can find out almost anything from here. Make sure you read through all of the comments in response to a request for help ... there can be important information in the discussion!
Make sure that you are looking at questions and answers about photon. Particle have other products. They are similar but there are some subtle differences.