Yeah I tried it;and it seems to work fine
It wasnt in my code but it was in the newer version of the blynk edgent example
Yeah I tried it;and it seems to work fine
It wasnt in my code but it was in the newer version of the blynk edgent example
Oh look, you were using a very early version of the Edgent example!
Pete.
I also want to add a door sensor to pin 14 and display the if the door is open or not on a widget lcd
is this correct
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME ""
#define BLYNK_FIRMWARE_VERSION "1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
const int wifists=2;
const int doorpin = 14;
int slider;
#include "BlynkEdgent.h"
BlynkTimer timer;
#define USE_NODE_MCU_BOARD
WidgetLCD lcd(V3);
BLYNK_WRITE(V7)
{
slider = param.asInt();
}
BLYNK_WRITE(V0)
{
int pin = param.asInt();
if (param.asInt()){
digitalWrite(16, LOW);
timer.setTimeout(slider, [] () {digitalWrite(16, HIGH);Blynk.virtualWrite(V0,LOW);} );
} else {
digitalWrite(16, HIGH);
}
}
BLYNK_WRITE(V1)
{
int pin = param.asInt();
if (param.asInt()){
digitalWrite(4, LOW);
timer.setTimeout(slider, [] () {digitalWrite(4, HIGH);Blynk.virtualWrite(V1,LOW);} );
} else {
digitalWrite(4, HIGH);
}
}
BLYNK_WRITE(V2)
{
int pin = param.asInt();
if (param.asInt()){
digitalWrite(5, LOW);
timer.setTimeout(slider, [] () {digitalWrite(5, HIGH);Blynk.virtualWrite(V2,LOW);} );
} else {
digitalWrite(5, HIGH);
}
}
void setup() {
Serial.begin(115200);
delay(100);
pinMode(16, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(wifists, OUTPUT);
digitalWrite(16,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
BlynkEdgent.begin();
timer.setInterval(1000L, connect);
timer.setInterval(100L, doorstate);
}
void connect()
{
{
if (Blynk.connected()) {
digitalWrite(wifists, HIGH);//turn on wifi status led if device isconnected to internet
} else {
digitalWrite(wifists, LOW);
}
}
}
void doorstate(){
if (digitalRead(doorpin) == HIGH) {
lcd.print(0, 0, "Door Closed");
}else{
lcd.print(0, 0, "Door Open");
}
}
BLYNK_CONNECTED(){
Blynk.syncVirtual(V7);
}
void loop() {
BlynkEdgent.run();
timer.run();
}