Go Down

Topic: Blink and LED while WiFi not Connected (Read 609 times) previous topic - next topic

Kernel Panic

@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?

Thanks in advance for all your help.



PS: Shameless plug: MUSHClient rocks!!   :D
--
Never argue with an idiot.  They will drag you down to their level and beat you with experience.

Arrch

Check out the TimerOne library; It's pretty simple to use.

UKHeliBob

This works for me
Code: [Select]
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>

boolean status = false;
boolean ledState = true;
int ledPin = 8;
int interval = 1000;
long previousMillis = 0;
long currentMillis;

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin,OUTPUT);
  while (status != WL_CONNECTED)
  {
    status = WiFi.begin("foo","bar");
    currentMillis = millis();
    if (currentMillis - previousMillis > interval)
    {
      previousMillis = currentMillis;
      ledState = !ledState;
      digitalWrite(ledPin, ledState);   
    }
  }
}

void loop(){}


NOTE 1
I do not actually have a WiFi shield so all bets may be off

NOTE 2
The WiFi library appears to stop some pins acting as digital outputs, notably pin 13, but it may affect others.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Nick Gammon


Nick Gammon


@Nick:  My code is over 400 lines and on several tabs.  The interval is 1000 as in the blink without delay example.


That's nothing. You can zip them up and make an attachment.

How to use this forum

Go Up