Styled button question

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() 
    pinMode(relaySwitch, OUTPUT);
    pinMode(reedSwitch, INPUT_PULLDOWN);
    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");
else {
Blynk.virtualWrite(3, 255);
Blynk.virtualWrite(0, "CLOSED");
Blynk.setProperty(V1,"offBackColor", "#00ff00");
openTimer = 0;


void loop() 



You never call void garageStatus(void)
and I don’t see any function that open or close the door :thinking:

Have you tried “onColor” and “offColor” instead?


SparkCorePolledTimer updateTimer(1000); //Create a timer object and set it's timeout in milliseconds

This line was missing on top.

The button in blynk sends directly to D0 …
That’s why i don’t know how to reach the button’s color…

Use virtual pins!


Found it! thanks Pete!