Page 194 - Programming the Photon Getting Started With the Internet of Things
P. 194
B
Particle Code Reference
This appendix will give you a basic understanding of different functions within the
Particle code, their correct syntax, return values, and a basic example of how to use that
function within your code.
Setup
This is a block of code that is executed only once your Photon board has booted up.
Example
void setup() {
//code is executed here only once
pinMode(D0, OUTPUT);
}
Loop
This is part of the code where it is executed repeatedly after the initial setup function.
Example
void loop () {
digitalWrite(led, HIGH);
delay(1000):
digitalWrite(led, LOW);
delay(1000);
}
This continuously turns a light-emitting diode (LED) on and off every 1 second.
analogRead
This obtains the value of a particular analog pin on the Photon board. The values range