Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By robs113
#42333 I have an Arduino sketch that animates LED strips.
I have moved it to an ESP8266 and if runs fine :D

I wish to control it via WiFi but..
The loop is busy animating LEDs so it cannot sit and wait for an incoming WiFi connection.

Would I be better to use an Arduino for the LED animation and an 8266 for the WiFi, then have the 8266 interrupt the Arduino when a WiFi command to alter the animation is received?

Advice appreciated.
User avatar
By woodat
#42646 The big issue you're probably encountering is you need to give the ESP enough time to do its wifi business between loops. The easiest way to do this is to add some short delays to your program.

Sadly I don't have a have a solid number of how long you need to delay in order to handle the wifi. I know 100ms works fine (I'm guessing 50 or even 20ms would probably do and not mess up your animations too badly but I don't know for sure if that's long enough for the ESP).

In theory it should do this automatically between iterations of your loop(), but I've found if you don't add at least some delay with the delay() command it doesn't spend enough time handling the wifi and just stops serving pages properly.

Anyone have any more solid numbers or thoughts on this? (I'm rather curious as well)
User avatar
By dkfradk
#42648 Hi.

Im doing something like this

Code: Select allvoid loop() {
  if (!runningApplication->getIsFinished()) {
    runningApplication->move();
    t = millis();
    yield();
    runningApplication->getPixels(pixels);
    yield();
    strip.show(pixels);
    yield();
  }
  while (millis() <= t + runningApplication->getDelay()) {
    webSocket.loop();
    server.handleClient();
  }
}


and it works flawlessly :)

UPDATE. Fixed some wrong brackets
User avatar
By Mmiscool
#42661 yeild() and delay(0) are functionally equivalent and will allow the wifi stuff to work its magic. Make sure you sprinkle these about your programs especially in any loops.