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;
}
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.
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.
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.