I have a Particle Photon that I am interfacing to Blynk. I can get buttons to work fine with their digital pins. I can’t seem to get the virtual pins with the Blynk LEDs to work.
I have a sample program that will blink the on-board LED when I assert a Blynk button on digital pin (0).
If I run the same program with the Blynk LED gadget, the Photon locks up as soon as the led1.on (also tried Virtual write) code is hit.
It seems that the #included Blynk library puts the photon out in the weeds.
Here is my code. Any thoughts on what I have wrong?
#include “blynk/blynk.h”
#include “SparkIntervalTimer/SparkIntervalTimer.h”
char auth[] = “adcf6c1bf99046969962862e273ad702”;
WidgetLED led1(V0); //register to virtual pin 0
// Create IntervalTimer object
IntervalTimer myTimer2;
// Pre-declare ISR callback functions
void blinkLED(void);
const uint8_t ledPin2 = D7; // LED for Interval Timer
int button = D0; // Button input pin (3.3v input)
void setup(void) {
Serial.begin(9600);
Blynk.begin(auth);
pinMode(D7, OUTPUT);
pinMode(button, INPUT_PULLDOWN);
myTimer2.begin(blinkLED, 5000, hmSec, TIMER4); // 5000 5 Seconds
}
void blinkLED(void) {
// digitalWrite(ledPin2,!digitalRead(ledPin2));
if (digitalRead(button) == HIGH) {
// led1.on();
digitalWrite(ledPin2,!digitalRead(ledPin2));
int state = !digitalRead(0);
Blynk.virtualWrite(V0, state);
} else {
// led1.off();
}
}
void loop(void) {
Blynk.run();
}