[SOLVED] IFTTT Action not working

I want an LED to blink when I get an email (IFTTT Trigger) but it will not work. I have the IFTTT setup and I just plugged in my led function into the sample code from the Particle website. When I compile it I don’t get any errors. I am very new to the developing side of this and I probably did something obvious wrong.

int brewCoffee(String command);
int led = D0;

void setup()
{
  // register the cloud function
  Particle.function("brew", brewCoffee);
  pinMode(led, OUTPUT);
}

void loop()
{
  // this loops forever
}

// this function automagically gets called upon a matching POST request
int brewCoffee(String command)
{
  // look for the matching argument "coffee" <-- max of 64 characters long
  if(command == "coffee")
  {
    //things that I want it to do
    digitalWrite(led, HIGH);
    delay(10000);
    digitalWrite(led, LOW);
    delay(2500);
    digitalWrite(led, HIGH);
    delay(10000);
    
    return 1;
  }
  else return -1;
}

What does your IFTTT recipe look like?

If any new email in inbox then call a function.

That much I figured, but the exact setup would be nice to know. A screenshot would be neat.

Here is is sorry. Also I know that it is from a specific email that was to make it easier to test.

It would be interesting to see which function you call and with what parameter.

You could also “remove” that parameter check in your function

  if(command == "coffee") // <-- remove that

Maybe also change your LED to int led = D7; to remove any risk of having a dud LED or wrong wiring play tricks on you.

1 Like

There is only one function available for me to call and it is “brew”

Could you explain to me what removing that would do so I can better understand the code, I also tested the LED with the blink an LED code and it worked so I the physical wiring seems to be fine.

There is indeed the brew function, but you can enter an argument for that.
In your particle code you check if the argument matches ‘coffee’. So either you send along that argument, or you take out the comparison.

1 Like

Since we can’t see if you are actually sending coffee to brew removing that parameter check would remove the need to show that part of your recipe. Any call - not only a call with correct parameter - would trigger the LED.

1 Like

It seems as though you’ve selected a pre-made recipe. With those you’re not able to change the argument it seems. Again, either remove the argument comparison, or create a recipe of your own, and set the argument to match whatever you need it to.

1 Like

It worked once I deleted the if command thanks for all of the help.

2 Likes