Hi guys,
I am trying to trigger the virtual pin 3 on my nodemcu using an ifttt applet that involves using webhooks but am not able to figure out what to fill in the webhooks part of the applet. ifttt requires two different applets for turning on and off the virtual pin. The virtual pin goes on when it receives a value of 1 from the button on the dashboard. Below is a snapshot of the applet and the code used on the nodemcu.
Would really appreciate if anyone could help me out on this one!! @Gunner
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Servo.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "**************************";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "*************";
char pass[] = "*************";
Servo servo;
void cradle() {
//you begin your own personal code for servo here
int pos;
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
//your personal code for servo should end here
}
BLYNK_WRITE(V3)
{
int pinValue = param.asInt();
if (pinValue == 1) { // if Button sends 1
cradle(); // start the function cradle
Blynk.run(); // Run rest of show in-between waiting for this loop to repeat or quit.
int pinValue = 0; // Set V3 status to 0 to quit, unless button is still pushed (as per below)
Blynk.syncVirtual(V3); // ...Then force BLYNK_WRITE(V3) function check of button status to determine if repeating or done.
}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
servo.attach(4); //attaches servo to pin 4 (D2 on node mcu)
}
void loop()
{
Blynk.run();
}