I'm trying to make a project using NodeMCU that show pictures in small OLED screen and also controlling WS2812 LED Ring.
I manage to do each of them separately but I'm not sure how to mix them together. The problem lies in the fact that most code examples for both the screen and the LED use sleep and that will of course only work for one of the other but not both.
This is the first project I've looked at to display bitmaps with SSD1306 screen and nodemcu.
This is the second project I've looked at to control NeoPixel WS2812 ring.
The main project was that both of them use delay
as a way to wait for some amount of time to "progress". But, I couldn't just wait because then it will mess up both the screen and the NeoPixel.
One more thing is I have to also take reading input into account. I still not 100% sure about the input but it will probably be potentiometer and maybe a button.
I think I have found the solution which is to break the large "tasks" of reading input, controlling screen and controlling leds into smaller parts and do the waiting in a cooperative way.
I've found this instructable which both explain how to do it and also provide code example.
I'll be glad to know if people how other ways to implement this.
I'm not sure how to mix them together
... how do you drink some water while eating dinner?BlinkWithoutDelay
(you can find that in the Arduino IDE by going toFiles
->Examples
->02.Digital
). That gives you an idea of how you can do your things without usingdelay()
. The third link you added uses that concept.