hello
i have a sensor to indicate if the door open or close and its working good however every time i connect to the blynk app and push the play button in the corner to go online the LCD doesnt shows the states unless i move the sensor again ,
so my q is wen am offline in the app and go online again it shows blank in the LCD ,i want an update ,other wise i have to be connected all the time .
but wen i go offline and online again in the app it dosnt update if its closed or open i have to move the sensor again
any help i would appreciate it this is my code
// This #include statement was automatically added by the Particle IDE.
#include "SparkCorePolledTimer/SparkCorePolledTimer.h"
// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"
// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"
//#define BLYNK_PRINT Serial
//#include "application.h"
#include "blynk/blynk.h"
#define GARAGE_ON D0
#define GARAGE_OFF D3
#define POWER D7
char auth[] = "xxxxxx";
//WidgetLED POWER(V1);
WidgetLCD lcd(V5);
int OldState;
void setup() {
//digitalWrite(POWER,HIGH);
Serial.begin(9600);
Serial.begin(115200);
Blynk.begin(auth);
Serial.print("Connecting");
while (Blynk.connect() == false) {
// Wait until connected
//Serial.print(".");
delay(100);
}
lcd.clear();
OldState=false;
// digitalWrite(POWER,HIGH);
pinMode(1,INPUT);
pinMode(GARAGE_ON,OUTPUT);
pinMode(GARAGE_OFF,OUTPUT);
pinMode(POWER,OUTPUT);
Particle.function("cloudFun1", fun1);
}
void loop() {
digitalWrite(POWER,HIGH);
Blynk.run();
if( digitalRead(1) != OldState ) // Stop hammering the server every loop
{
OldState=digitalRead(1);
lcd.clear();
if( digitalRead(1) == 0)
{
lcd.print(0,0, " Garage Door");
lcd.print(5, 1, "Closed");
}
else
{
lcd.print(0,0, " Garage Door");
lcd.print(6, 1, "Open");
}
}
}
int fun1(String args) {
digitalWrite(GARAGE_OFF, HIGH);
delay(500);
digitalWrite(GARAGE_OFF, LOW);
return 1;
}
.