Hi All, i’m new here!
I’ve set up a garage door automation with Blynk controlling a particle Photon. I also have a ree switch connected to check the closed status of the door. It works all good. When i push the button in blynk garage opens or closes. I have a virtual LED and textbox saying if the door is open or closed.
I wanted to get this in a styled button. The button works for opening and closing the door, but i would like the backgroundcolor of the door to be red when open and green when closed. I can’t get this to work right now. Been testing some… I will post my code, can anyone help?:
void garageStatus(void);
const int reedSwitch = A0;
const int relaySwitch = D0;
int reedStatus = 0;
int ledStatus = 0;
int openTimer = 0;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
pinMode(relaySwitch, OUTPUT);
pinMode(reedSwitch, INPUT_PULLDOWN);
updateTimer.SetCallback(garageStatus);
reedStatus = digitalRead(reedSwitch);
}
void garageStatus(void)
{
reedStatus = digitalRead(reedSwitch);
if (reedStatus == LOW) {
Blynk.virtualWrite(3, 112);
Blynk.virtualWrite(0, "OPEN");
Blynk.setProperty(V1,"onBackColor", "#D3435C");
openTimer++;
}
else {
Blynk.virtualWrite(3, 255);
Blynk.virtualWrite(0, "CLOSED");
Blynk.setProperty(V1,"offBackColor", "#00ff00");
openTimer = 0;
}
}
void loop()
{
Blynk.run();
updateTimer.Update();
}