Hey Blynkers,
I’m a noob wanting to use a Wemos D1 mini + arduino IDE to open my garage door. The issue I’ve got is getting a relay to act like a momentary push switch. In the Blynk app, its fine. Just set the button to ‘push’. The problem is, I also want to be able to open/close the door using IFTTT webhooks. This works, however it latches the pin high = relay latches closed. I was hoping to use some code to get something like webhook pulls virtual pin high - code in Wemos detects pin is high - runs a loop pulling the digital pin high for a second then low again.
I’ve looked for an answer in these forums, but still haven’t been able to pull it off. I’m not a coder at all, the following was copy/pasted from other projects here, but doesn’t work. I’m sure this is a fairly simple task, can anyone help?
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer tripWire;
// 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[] = "";
int outputPin = D5;
int inputPin = V1;
int val = 0;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
//pasted code starts here
BLYNK_WRITE(inputPin) {
int pinValue = param.asInt();
if (pinValue==HIGH) { // virtual pin V1 goes HIGH when pressed in the app, goes LOW when released.
tripActivate();
}
}
void tripActivate() {
digitalWrite(outputPin, HIGH);
tripWire.setTimeout(1000L, tripDeactivate);
}
void tripDeactivate() {
digitalWrite(outputPin, LOW);
}
//pasted code ends here
void loop()
{
Blynk.run();
}