AVOID factory reset - What to do with unexpected LED behavior on a Photon

As you are using Windows you need the proper drivers for DFU Mode

  • Download [zadig][1]
  • Put your Photon in DFU Mode
  • Start zadig and click “Options - List All Devices
  • Select your Photon in the drop-down-list
  • Install libusbK

Then try again
[1]: http://zadig.akeo.ie/

That works, I am now able to update my Photon but unfortunately it just brings me back to where I started: Solid white 1 second, 3 rapid green blink, 3 magenta and then a bunch of red blinks and then it repeats forever.

Try DFU mode with particle flash --usb tinker?

It works! My particle is now breathing magenta again.

BUT when I try to flash my own code it goes bananas again. Is it my code that screws up my Photon?

Cyan I hope?

If it works without your code, and it doesn't with your code, then I'd suggest looking there for the cause :wink:

We could take a look if you want to share the code?

Ok if you promis not to laugh?

To be honest I don’t remember what the last code I entered was, it has been too long and too many frustrations since I last edited the code.

int day = 0;
int Time1[4];
int Time2[4];
int Time3[4];
int Time4[4];
int Time5[4];
int Time6[4];
int Time7[4];
int startHour = 0;
int startMinute = 0;
int stopHour = 0;
int stopMinute = 0;
retained int mode = 0;
int oldMode;
char publishMode[2];
char publishTime1[4];
char publishTime2[4];
char publishTime3[4];
char publishTime4[4];
char publishTime5[4];
char publishTime6[4];
char publishTime7[4];
String str;
//String str2;
int publishModeInteger;
int manualTime = 0;
int timeLastPublish;
int publishDelay = 15;
bool timeTime = false;
bool block1 = true;

void setup() {
    Serial.begin(9600);
    
    Particle.function("parseTime",parseTime);
    Particle.function("mode",modeToggle); 
    Particle.function("manualTime",parseManualTime);
}

void loop() {
    str = String(mode);
    
    if (Time.now() > timeLastPublish + publishDelay &&  block1) {
        sprintf(publishTime1,"1~%i~%i~%i~%i",Time1[0],Time1[1],Time1[2],Time1[3]);
        Serial.print("publishTime1: \"");
        Serial.print(publishTime1);
        Serial.println("\"");
        Particle.publish("publishTime1",publishTime1);
        sprintf(publishTime2,"2~%i~%i~%i~%i",Time2[0],Time2[1],Time2[2],Time2[3]);
        Particle.publish("publishTime2",publishTime2);
        sprintf(publishTime3,"3~%i~%i~%i~%i",Time3[0],Time3[1],Time3[2],Time3[3]);
        Particle.publish("publishTime3",publishTime3);
        sprintf(publishTime4,"4~%i~%i~%i~%i",Time4[0],Time4[1],Time4[2],Time4[3]);
        Particle.publish("publishTime4",publishTime4);
        block1 = false;
    }
    
    if (Time.now() > timeLastPublish + publishDelay + 7) {  
         Serial.print("publishTime 2");
        sprintf(publishTime5,"5~%i~%i~%i~%i",Time5[0],Time5[1],Time5[2],Time5[3]);
        Particle.publish("publishTime5",publishTime5);
        sprintf(publishTime6,"6~%i~%i~%i~%i",Time6[0],Time6[1],Time6[2],Time6[3]);
        Particle.publish("publishTime6",publishTime6);
        sprintf(publishTime7,"7~%i~%i~%i~%i",Time7[0],Time7[1],Time7[2],Time7[3]);
        Particle.publish("publishTime7",publishTime7);

        str.toCharArray(publishMode,2);
        Serial.print("publishMode: \"");
        Serial.print(publishMode);
        Serial.println("\"");
        oldMode = mode;
        Particle.publish("mode",publishMode);
        block1 = true;
        timeLastPublish = Time.now();
    }
    
    if (mode != oldMode) {
            str.toCharArray(publishMode,2);
            oldMode = mode;
            Particle.publish("mode",publishMode);
        }
    
}

int parseTime(String command){
    char charBuf[20];
    command.toCharArray(charBuf, 20);
    
    //Begin black magic supplied by @mdma at:
    // https://community.spark.io/t/gpio-control-via-gui/6310/7
    const int value_count = 8;  // the maximum number of values
    int values[value_count];    // store the values here
    
    char string[20];
    strcpy(string, charBuf);  // the string to split
    int idx = 0;
    for (char* pt=strtok(string, "~"); pt && idx<value_count; pt=strtok(NULL, "~")) {
       values[idx++] = atoi(pt);
    }
    //End black magic.
    
    day = values[0];
  
    if (day == 1) {
        for (int i = 1; i < 5; i++) {
            Time1[i-1] = values[i];
            Serial.println(Time1[i-1]);
        }
    } else if (day == 2) {
        for (int i = 1; i < 5; i++) {
            Time2[i-1] = values[i];
        }
    } else if (day == 3) {
        for (int i = 1; i < 5; i++) {
            Time3[i-1] = values[i];
        }
    } else if (day == 4) {
        for (int i = 1; i < 5; i++) {
            Time4[i-1] = values[i];
        }
    } else if (day == 5) {
        for (int i = 1; i < 5; i++) {
            Time5[i-1] = values[i];
        }
    } else if (day == 6) {
        for (int i = 1; i < 5; i++) {
            Time6[i-1] = values[i];
        }
    } else if (day == 7) {
        for (int i = 1; i < 5; i++) {
            Time7[i-1] = values[i];
        }
    } 
    timeTime = true;
    return 0;
}

int modeToggle(String command) {
      if (command=="on") {
        Serial.println("On");
        mode = 1;
        return 1;
    }
    else if (command=="off") {
        Serial.println("Off");
        mode = 0;
        return 0;
    }
    else if (command=="auto") {
        Serial.println("Auto");
        mode = 2;
        return 2;
    }
    else {
        return -1;
    }
}

int parseManualTime(String command) {
    Serial.println(command);
    manualTime = command.toInt(); 
    Serial.print("Manual time");
    Serial.print(manualTime);
    Serial.println();
    mode = 3;
    return 0;
}