int led1Pin = D2;
int led2Pin = D10;
void setup() {
pinMode(led1Pin, OUTPUT);
digitalWrite(led1Pin, LOW);
pinMode(led2Pin, OUTPUT);
digitalWrite(led2Pin, LOW);
Particle.function("led1", led1Control);
Particle.function("led2", led2Control);
}
void loop()
{
// Nothing to do here
}
int led1Control(String command)
{
int state = LOW;
// find out the state of the led
if(command == "HIGH"){
state = HIGH;
}else if(command == "LOW"){
state = LOW;
}else{
return -1;
}
// write to the appropriate pin
digitalWrite(led1Pin, state);
return 1;
}
int led2Control(String command)
{
int state = LOW;
// find out the state of the led
if(command == "HIGH"){
state = HIGH;
}else if(command == "LOW"){
state = LOW;
}else{
return -1;
}
// write to the appropriate pin
digitalWrite(led2Pin, state);
return 1;
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .