That test can be completely eliminated and has nothing to do with getting the status of a BLYNK push button, it was just for my assurance. My question/need is “how to receive the status of a push button from the app to make a decision in the Photon code?”
The function “checkIfWorking()” is now optional, and I can call it in loop() to limit flooding if I need assurance BLYNK is still responding.
Here is revised code for the TEST. PLEASE SHOW ME how to retrieve the Push Button status. Thank you
#include “blynk/blynk.h”
#define ON 255
#define OFF 0
int pinData = ON; // change this global variable to prove code is functioning
long prevMillis = 0;
long interval = 100;
bool isFirstConnect = true;
char BlynkToken[] = “9999999999999999999999999999999”;
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void setup()
{
Blynk.begin(BlynkToken);
delay(5000); // give time to settle
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BLYNK_CONNECTED() // runs every time Blynk connection is established
{
if (isFirstConnect)
{
// Request server to re-send latest values for all pins
Blynk.syncAll();
isFirstConnect = false;
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BLYNK_READ(V0) //Function to set status of BLYNK widget on Android
{
Blynk.virtualWrite(V0,pinData);
// what code can be entered here to send or receive info from the push button?
Particle.publish("BLYNK_READ executed : ", String(pinData));
}
//xxxxxxxxxxxx[ Widget Button using virtual pin # 0 ]xxxxxxxxxxx
BLYNK_WRITE(V0) //Function to get status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state)
{
Blynk.virtualWrite(V5, ON);
// what code can be entered here to send or receive info from the push button?
Particle.publish("BLYNK_WRITE executed : ", String(ON));
}
else
{
Blynk.virtualWrite(V5, OFF);
Particle.publish("BLYNK_WRITE executed : ", String(OFF));
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void loop()
{
Blynk.run();
// checkIfWorking(); // call to see if BLYNK is responding if needed
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void checkIfWorking() // this is just to comfort me that BLYNK is still responding
{
unsigned long curntMillis = millis();
if( curntMillis - prevMillis > interval)
{
prevMillis = curntMillis;
Blynk.virtualWrite(V3, pinData); // virtual LED
Particle.publish("Data value of pinData: ", String(pinData));
}
}