Fading Green Light


I have been using Spark and Photon for weeks and I have never seen that behaviour. I have upload a code in a Photon it connects to the network and starts breathing cyan.

After a few seconds or minutes (it changes when I reset it) it starts breathing green. In it does not do what it is supposed to do.

This photon it is powered buy an external ac/dc power adapter.

In other hand, I have another photon with the same code (which was uploaded before) powered buy another ac/dc power adapter and it is working perfect.

I have started to see this behaviour after I started using millis() instead delay() in my code:

I have declared a global variable: long tiempo = 0;

Then in loop() I have:

tiempo = millis() + 5000; //for a delay of 5 seconds
while (tiempo > millis())


Have you tried swapping the photons to make sure there isn’t an issue with the power supply? If that’s the only difference in the setup, that’s something I’d look at first.

1 Like

I am doing changes in the code and when I swap the “millis delays” for standard “delay” it works fine. So I think it has to be something related whith it.

I can’t swap the photons because the one which problems is soldered in a pcb with the ac/dc transformer also soldered on it. I have been using this “board” since weeks and I didn’t have any problems with it.

One thing: You need unsigned long rather than normal/signed long when doing this and you should also rather do it like this

while (millis() - tiempo < 5000)

to avoid type incompatibilities (to word it very basic).

And if you have longer running loops make sure to call Particle.process(); regularly to keep the cloud connected.


Both Photons haven’t got exactly the same code, but both have finished fading green light.

I have checked that both have the same behaviour under the same code.

After that I modified the code following your instructions ScruffR

I will comment if it has solved the problem or not.

Thank you very much.

For others getting a green fading LED that needs explanation - you will also get this LED status if the Photon isn’t given time to maintain the cloud connection. A lot of example code will use this way of trapping errors:

while (1);

In other microcontrollers (such as AVR-based Arduino’s) this isn’t a problem, but in such a loop (I suspect that) the RTOS on the Photon won’t be able to maintain it’s connection. This makes it impossible to reprogram it, so if you instead just add a small delay in the the while-loop you’ll avoid this:

while (1)

This works because the RTOS also does it’s job while performing a delay-loop.


Actually the preferable solution would be

  while(1) Particle.process();

Apart from being clearer about the actual meaning of the loop action with Particle.process() the above proposed version would only perform cloud tasks once every accumulated second of delays (every 100th iteration of while()) since delay() implicitly calls Particle.process() only that “often”.

1 Like