Back to Parent

int ledPin = D2;
int buttonPin = D4;
bool doLED = false;

void setup() {

    pinMode( ledPin, OUTPUT);
    pinMode( buttonPin, INPUT_PULLUP);

    Particle.subscribe( "blinkLED", handleActivateLED );
    blinkLED( 3, ledPin );

}

void loop() {

    int buttonValue = digitalRead( buttonPin );
    if( buttonValue == LOW ){
        Particle.publish( "doPairedPublish" );
    }

    if( doLED == true ){
        blinkLED( 6, ledPin );
        doLED = false;
    }

    delay( 1000 );

}

void handleActivateLED( const char *event, const char *data)
{
   doLED = true;
}
void blinkLED( int times, int pin ){
    
    for( int i = 0; i < times ; i++ ){
        digitalWrite( pin, HIGH );
        delay( 500 );
        digitalWrite( pin, LOW );
        delay( 500 );
    }
    
}
Click to Expand

Content Rating

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

0