Now the same example using IFTTT:
int inputPin = D1; //push-button pin
int val = 0; //variable for push-button status
int state = 1; //variable for on/off state
int led = D7; // integrated LED
void setup() {
pinMode(inputPin, INPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
val = digitalRead(inputPin); //read the state of the push-button
if (val == LOW) { //if push-button pressed
state = !state; //reverse on/off state
delay(250); //primitive button debounce
Serial.println("button pushed!");
digitalWrite(led, HIGH); // Turn ON the LED pins
notification();
}
}
void notification()
{
delay(1000);
Spark.publish("button1",NULL, 60, PRIVATE);
//
Serial.println("Complete");
//
digitalWrite(led, LOW); // Blink LED
delay(250);
digitalWrite(led, HIGH);
delay(250);
digitalWrite(led, LOW);
}
Out of curiosity,
how does one detect if an IFTTT request does not get published?
Thanks very much,
Stuart
I’ve edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy