Back to Parent

int led1 = D2;
int led2 = D3;

void setup() {
    
    pinMode(led1, OUTPUT);
    digitalWrite(led1, LOW);
    pinMode(led2, OUTPUT);
    digitalWrite(led2, LOW);
    Particle.function("led", ledControl);

}

void loop() {
    //nothing here
    

}

int ledControl(String command){
    int state1 = LOW;
    int state2 = LOW;
    if(command == "LED1"){
        state1 = HIGH;
    } else if(command == "LED2"){
        state2 = HIGH;
    } else {
        return -1;
    }
    
    digitalWrite(led1, state1);
    digitalWrite(led2, state2);
    
    return 1;
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0