Why does the code below endlessly loop into the sub function (blinkled) and blink the virtual LED constantly when i’m not even pressing the virtual button ? [I’m programming the spark photon]
WidgetLED led0(0);
WidgetLED led1(1);
int outputpin = D7;
BLYNK_WRITE(V2) //Button Widget 'OVERRIDE' is writing to pin V2 assigned to one of the buttons
{
blinkled();
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
pinMode(outputpin,OUTPUT);
digitalWrite(outputpin,LOW);
Override = 0;
}
void loop()
{
Blynk.run();
}
//-----------------------------------Sub------------------------
void blinkled()
{
digitalWrite(outputpin,HIGH);
delay(2000);
changeledstate();
delay(2000);
changeledstate();
delay(2000);
digitalWrite(outputpin,LOW);
}
void changeledstate()
{
if (led1.getValue()) {
led1.off();
}else{
led1.on();
}
}
Do you have any suggestions (code wise) as to do what I’m trying to do? Basically I want to enter into a sub function on a button press and turn on a virtual LED… All of your examples use timers and none use a vButton/vLED combo.