Can I stop Photon from running its program on restart?

I have a Photon attached to a relay flashed with the following code. I am running it through the Blynk app on my phone. Everything works great, except that I found if the power goes out and then comes back on, the Photon powers back on and sends power to the relay. Is there a way to stop this from happening? I only want the relay to be powered when I press the button on my Blynk app.

#include "blynk/blynk.h"
char auth[] = "<AUTH_CODE_HERE>";
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);
  pinMode(D0, OUTPUT);
}
void loop()
{
    Blynk.run();    
}

@BreakingBlynk, you set the pinMode() for D0 but you can also set the start value to HIGH or LOW to turn off your relay using digitalWrite() in setup() :smile:

1 Like

So I am a total newbie with this. I am normally great at copying other people’s code and making it work for what I want it to do but this is my first project so I am still learning on this stuff. I added a digitalWrite(D0,LOW); in several different places and I am still getting the same result. When I cut the power and then turn it back on, power is sent to the relay. Below is the last code update. Can you better explain where I need to put the digitalWrite(D0,LOW); so that when the Photon gets power it doesn’t send power to the relay until I depress the D0 button on the Blynk app?

void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
pinMode(D0, OUTPUT);
digitalWrite(D0,LOW);
}

Thank you!