im having some issues with my button widget. when i use the button in the app, it performs the way i want it to. im trying to blynk.virtualwrite(v6,LOW); from else where in my code to put the button in low state, it dos but the button dosnt do anything, not like it dos when you press it in the app.
belowis the code related to the problem im having.
BLYNK_WRITE(V1){ // Return pump button off
int value = param.asInt(); // Get State of Virtual Button, Return pump
if (value == 1) { // button ON
// Turn as many pins/relays ON as you need
digitalWrite(relay3Pin, LOW);
timer.setTimeout(30000, relaysOn);
} else { // button OFF
// Turn as many pins/relays OFF as you need
digitalWrite(relay3Pin, HIGH);
digitalWrite(relay4Pin, HIGH);
Blynk.virtualWrite(V2, LOW);// Skimmer
digitalWrite(relay5Pin, HIGH);
Blynk.virtualWrite(V3, LOW);// Reactor
Blynk.virtualWrite(V6, LOW);// Wavemakers
Blynk.virtualWrite(V8, LOW);// Heating
digitalWrite(relayPin, LOW);
Blynk.virtualWrite(V9, LOW);// Cooling
digitalWrite(relay2Pin, HIGH);
}
}
this it the button im refering to
BLYNK_WRITE(V6) // wavemakers
{
wavesw = param.asInt(); // Get State of Virtual Button, Return pump
if (wavesw == 1) {
wavecontrol();
}
else
{
digitalWrite(wave1Pin,LOW);
digitalWrite(wave2Pin,LOW);
}
}
and the wave control here.
void wavecontrol()
{
if(wavesw == 1)
Serial.print("\n");
Serial.println(":: Executing check loop this minute");
if ((CounterOn > 0) && (ledStatus == 0) && (wavesw == 1))
{
digitalWrite(wave1Pin,HIGH); //write to pin to turn the LED on.
digitalWrite(wave2Pin,LOW);
Serial.print(": LED on\n");
ledStatus = 1;
CounterOff = 0;
}
if ((CounterOn > 0) && (ledStatus == 1))
{
CounterOn = (CounterOn - 1);
}
if ((CounterOff == 0) && (CounterOn == 0) && (ledStatus == 1) && (wavesw == 1))
{
CounterOff = onsec;
}
if ((CounterOff > 0) && (ledStatus == 1))
{
digitalWrite(wave1Pin,LOW); //write to pin to turn wave1 off
digitalWrite(wave2Pin,HIGH);//write to pin to turn wave2 on
Serial.print(": LED off\n");
ledStatus = 0;
CounterOn = 0;
}
if ((CounterOff > 0) && (ledStatus == 0))
{
CounterOff = (CounterOff - 1);
}
if ((CounterOff == 0) && (CounterOn == 0) && (ledStatus == 0))
{
CounterOn = offsec+1;
}
}