Hi.
I have about 6 photons.
But when I flash this code the photon disconnects and starts breathing green, but only when I do a flash of the code.
If I press the restart button on the photon, all works fine with the new code…
Could it be something in the MCP23008-I2C.h file ? I haven’t used that before this projekt 
The code is for lighting on a staircase, with two sensors (top or bottom - not in code yet)
and an uplink to blynkk and the master controller- only for signals for light on or off.
I have tried a lot of things, system thread / system mode / particle process.
Any help would be awesome 
SYSTEM_THREAD(ENABLED);
// De gamles trappe Bund app
#include <MCP23008-I2C.h>
#include <blynk.h>
Adafruit_MCP23008 mcp_0;
char auth[] = "###";
WidgetBridge bridge1(V0);
STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));
int Antal_Top=0,Antal_Bund=0,Timer_step,Timer_sluk;
unsigned long tid;
bool ON=0,opad_on=0,nedad_on=0,OFF=0;
void setup() {
Serial.begin(9600);
delay(1000); // Allow board to settle
WiFi.setCredentials("Paradis", "###");
WiFi.setCredentials("Hoerup", "###");
//Particle.connect();
//Particle.syncTime();
Blynk.begin(auth);
Blynk.syncVirtual(V11,V12,V21,V22); // update values from blynk server
mcp_0.begin(0);
for(int i = 0; i <= 7; i++)
{
mcp_0.pinMode(i, OUTPUT);
}
Particle.process();
for(int i = 0; i<=9 ; i++){
mcp_0.digitalWrite(i, HIGH);
//digitalWrite(i,HIGH);
}
}
BLYNK_CONNECTED() { // Connect with Top controller
bridge1.setAuthToken("###"); // Auth of Top contrl.
} // Connect with Top controller
BLYNK_WRITE(V1) { // Opad
if(param.asInt()){
opad_on = 0;
opad();
}
} // Opad
BLYNK_WRITE(V2) { // Nedad
if(param.asInt()){
nedad_on = 0;
nedad();
}
} // Nedad
BLYNK_WRITE(V3) { // Sluk alt
if(param.asInt()){
for(int i = 0; i<9 ; i++)
{
mcp_0.digitalWrite(i, LOW);
//digitalWrite(i,LOW);
delay(Timer_step);
Particle.process();
}
opad_on = 0;
nedad_on = 0;
}
} // Sluk alt
BLYNK_WRITE(V4) { // Tænd alt
if(param.asInt()){
for(int i = 0; i<9 ; i++)
{
mcp_0.digitalWrite(i, HIGH);
//digitalWrite(i,HIGH);
delay(Timer_step);
Particle.process();
}
opad_on = 0;
nedad_on = 0;
}
} // Tænd alt
BLYNK_WRITE(V11) { // Timer til step
Timer_step = param.asInt();
} // Timer til step
BLYNK_WRITE(V12) { // Timer til slut
Timer_sluk = param.asInt();
} // Timer til slut
BLYNK_WRITE(V21) { // Antal top
Antal_Top = param.asInt();
} // Antal top
BLYNK_WRITE(V22) { // Antal Bund
Antal_Bund = param.asInt();
} // Antal Bund
void opad(){ // Opad
if(!opad_on){
tid=millis();
for(int i = 0; i<9 ; i++)
{
mcp_0.digitalWrite(i, LOW);
//digitalWrite(i,LOW);
delay(Timer_step);
Particle.process();
}
opad_on = 1;
}else{
for(int i = 0; i<9 ; i++)
{
mcp_0.digitalWrite(i, HIGH);
//digitalWrite(i,HIGH);
delay(Timer_step);
Particle.process();
}
Antal_Top += 1;
bridge1.virtualWrite(V21, Antal_Top);
opad_on = 0;
}
} // Opad
void nedad(){ // Nedad
if(!nedad_on){
tid=millis();
for(int i = 8; i>=0 ; i--)
{
mcp_0.digitalWrite(i, LOW);
//digitalWrite(i,LOW);
delay(Timer_step);
Particle.process();
}
nedad_on = 1;
}else{
for(int i = 8; i>=0 ; i--)
{
mcp_0.digitalWrite(i, HIGH);
//digitalWrite(i,HIGH);
delay(Timer_step);
Particle.process();
}
Antal_Top += 1;
bridge1.virtualWrite(V21, Antal_Top);
nedad_on = 0;
}
}// Nedad
void loop() {
Blynk.run();
if(opad_on == 1)
{
if(tid<(millis()-Timer_sluk*1000)){
opad();
}
}
if(nedad_on == 1)
{
if(tid<(millis()-Timer_sluk*1000)){
nedad();
}
}
}


