How do I start an async process?

I have the internet button. What I want to do is have the button trigger an led to flash while it makes a http request. When that request comes back I want to stop the flashing and trigger another LED.
It’s not immediately clear to me on how to begin with this.

You can use the excellent SparkIntervalTimer library that uses hardware timers to perform a task repeatedly at a given time interval. In our case, the task will be to blink the LED.

In outline, here’s the steps:

  • before starting the HTTP connection, create a new timer with a timeout set to the speed the LED should blink at. I’ve written an example timer function below.

  • start the HTTP connection

  • when the HTTP connection is finished, stop the timer, turn off the flashing LED, and then turn on the other LED.

The timer callback function to blink the LED might look something like:

void blink_led()
     const int LED = D3;
     digitalWrite(LED, !digitalRead(LED));

That’s the steps in outline.

Looks very interesting! Thank you for pointing me to the interval timer.

In 0.4.7, which was released after I wrote the advice above, we added software timers.