Page 43 - Programming the Photon Getting Started With the Internet of Things
P. 43
if(pin.startsWith("D")){
pinMode(pinNumber, INPUT);
return analogRead(pinNumber);}
else if (pin.startsWith("A")){
pinMode(pinNumber+10, INPUT);
return analogRead(pinNumber+10);}
return -2;}
int tinkerAnalogWrite(String command){
int pinNumber = command.charAt(1) - '0';
if (pinNumber< 0 || pinNumber >7) return -1;
String value = command.substring(3);
if(command.startsWith("D")){
pinMode(pinNumber, OUTPUT);
analogWrite(pinNumber, value.toInt());
return 1;}
else if(command.startsWith("A")){
pinMode(pinNumber+10, OUTPUT);
analogWrite(pinNumber+10, value.toInt());
return 1;}
else return -2;}
Using the Particle Web IDE
The Particle Web integrated development environment (IDE) is a simple Web interface
that you can use to program your Photon. You can also get useful information and settings
about your Photon from here, as well as access tokens for use with the Particle API. To
access the Particle IDE, simply head to https://www.particle.io/build. If you have not
previously registered for an account, go ahead and create one simply by entering your
current e-mail address and password (see Figure 2.7). Registering for an account allows
you to save your programs and assign devices to your account. If you have logged into the
Particle Build webpage before, then click the Let Me Login button underneath the sign-up
button.