What is the earliest moment after startup to light a LED, and how do I get there?

I am trying to light some LEDs as soon as possible after the Particle Core has been powered on (function test).

However, sometimes it takes more than 10 seconds until the first instruction in setup() is processed. I assume this is because the Core tries to connect to the network first. How can I do something before that? Is setup() the right place?

Thank you!


void setup() {
    pinMode(D7, OUTPUT);

void loop() {


1 Like

@Sleziak nailed it.

For more info on SYSTEM_MODE(SEMI_AUTOMATIC), check out https://docs.particle.io/reference/firmware/photon/#system-modes.

In the 0.4.4 firmware, we have the STARTUP() macro that you can use for early execution, so you don’t have to change system mode:

void init_led()
    pinMode(D7, OUTPUT);


If you're using a Core, the 0.4.5 firmware will be released tomorrow.

Wow, that is so great. Thank you, all!