Get Help

Since I am doing a project about the LDR ,IFTTT and Blynk App
But now I am facing some problem I don’t know how to fix it.
My plan is when I am using Blynk App switch on the button then the light will on.
so that it can let LDR to get the light value.
When the LDR get the light value is higher than 1000
it will send a request to IFTTT so that have next action


Now the problem is LDR can not success pass the sensorValue to sendrequest() this function.

But when I am try to print out sensorValue in the loop function , it is success

Since I don’t want to put the makeIFTTTRequest() in the loop. It may receive a lot of request.

And I want to switch on off again, if the light value still higher than 1000, it need to send

makeIFTTTRequest() one more time.


Here is some of my coding

int sensorValue;
void loop()
{
Blynk.run();
timer.run();
if (digitalRead(btnPin) == LOW) {
sensorValue = analogRead(A0);
delay(500);
// Serial.println(sensorValue);
}
}

void sendrequest() {
if (sensorValue >= 1000) {
makeIFTTTRequest();
Serial.println(sensorValue);
}
}

Here is some of my coding

Here is some of my answer

The code you posted does not call the sendrequest() function

UKHeliBob:
Here is some of my answer

The code you posted does not call the sendrequest() function

When I am try to put sendrequest() into the void loop(), it will keep to sending the request.

like this :

void loop()
{
Blynk.run();
timer.run();
if (digitalRead(btnPin) == LOW) {
sensorValue = analogRead(A0);
delay(500);
// Serial.println(sensorValue);
sendrequest()
}
}

When I am try to put sendrequest() into the void setup(), it will not action for makeIFTTTRequest.

I want to get the sensorValue is higher than 1000 just sent once time of the request, even few seconds later the sensorValue still higher than 1000.

Where should need to modify ?

Where should need to modify ?

It looks like you should change the program to only send the request when sensorValue becomes greater than or less than the trigger value rather than the value is above or below it.

See the StateChangeDetection example in the IDE

Thanks a lot!! I made it! :slight_smile:

nino19830617:
Thanks a lot!! I made it! :slight_smile:

Good news !

Remember the technique for future projects