I have a nice working project and I'm looking to add a little flash to my visual feedback. While the Arduino (WiFi Shield) is connecting to the network via the while loop,
while (status != WL_CONNECTED)...
I want to have an LED blink. Once it's connected, I want the LED to go solid. Right now, I just have the LED turn on once it's connected. How can I blink an LED during this connection process? Is it possible? Do I have to implement an interrupt? That's new territory for me.
Thank you for your reply. After reading the blink without delay page, I'm not sure that will apply here because the code waits for a connection before it does anything.
// Attempt to connect to WiFi network.
while (status != WL_CONNECTED) {
Serial.println("WiFi Shield Online");
Serial.println();
Serial.print("Connecting to ");
Serial.print(ssid);
Serial.println(" Network ...");
//status = WiFi.begin(ssid, keyIndex, key); // WEP
status = WiFi.begin(ssid, key); // WPA/WPA2
// Blink networkPin until connection is established.
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(networkPin, ledState);
}
//tenCountDot();
//delay(10000); // Wait 10 seconds for WiFi to connect.
}
I tried putting the blink code both in before and after the status = WiFi.begin() statement. No difference. What am I missing?
@Nick: My code is over 400 lines and on several tabs. The interval is 1000 as in the blink without delay example.
@Aarch: I figured it would end up an interrupt situation. Not afraid of them just not familiar with them. As far as rewriting the WiFi.begin() function, I haven't thought about it as it's the original library released with 1.0.3.
Any ideas how to blink the LED in the background until the WiFi.begin() function completes?