Back to Parent

// Mr Java: Push button -> JSON Payload -> IFTTT -> Spotify

// Switch button
int pushBtn = D3;

void setup() {
    Serial.begin(9600);

    // Push button
    pinMode(pushBtn, INPUT_PULLUP);
}

void loop() {
    int switchState = digitalRead(pushBtn);

    // Check if the button is pressed
    if (switchState == LOW) {
        // Publish event
        Particle.publish("coffeeTrigger");
        
        // Delay to avoid multiple triggers
        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