Hello I’m looking for some help, i need to switch 2 relays off with one button within the app. Do I need to include anything in my code to do this?
Thanks in advance
Just a combination of reading the Blynk documentation, using virtual pins and knowing a little Arduino code…
http://docs.blynk.cc/#blynk-firmware-virtual-pins-control
http://docs.blynk.cc/#blynk-firmware-blynktimer-blynk_writevpin
https://www.arduino.cc/reference/en/
int value;
int relaypin1 = 2; // example digital pin for relay 1
int relaypin2 = 3; // example digital pin for relay 2
BLYNK_WRITE(vPin) { // Set to your Buttons vPin
value = param.asInt(); // Get State of Virtual Button
If (value == 1) { // button ON
// Turn as many pins/relays ON as you need
digitalWrite(relaypin1, HIGH);
digitalWrite(relaypin2, HIGH);
} else { // button OFF
// Turn as many pins/relays OFF as you need
digitalWrite(relaypin1, LOW);
digitalWrite(relaypin2, LOW);
}
ok so would i add this bit under the void loop () section as it wiuld need to keep running?
BLYNK_WRITE(vPin) { // Set to your Buttons vPin
value = param.asInt(); // Get State of Virtual Button
If (value == 1) { // button ON
// Turn as many pins/relays ON as you need
digitalWrite(relaypin1, HIGH);
digitalWrite(relaypin2, HIGH);
} else { // button OFF
// Turn as many pins/relays OFF as you need
digitalWrite(relaypin1, LOW);
digitalWrite(relaypin2, LOW);
}
you must add that , outside the void loop.