Hi, am very new to Arduino IDE and am having troubles getting to grips with some of the programming. I have a project where I am looking for some guidance fo rhow best it should be done.
Essentially what I already have working is:
NodeMCU board running HTTP server connected to WiFI network.
Different URLs setup eg <<IP_Address>>/programA
I also have some WS8266 LEDs connected and have working programs using the Adafruit NeoPixel commands.
What I need to happen is:
If a URL of /programA is called, I need it to run one Adafruit led program (eg rainbow) and keep repeating that "program".
But I need it to be able to stop and run a different program if a different URL is called eg /programB.
I'm confused as to which parts should go in void setup and which parts in voip loop
I'm assuming I need something like:
When URL /programA is called, set variable "program_name" to "A".
Then have a loop that says while "program_name" = "A" run (and loop) this sub-program (eg rainbow led).
Then when URL /programB is called, change the variable and have a different "while" loop run a different sub-program.
But every time I play around with this, once the first program is running, nothing is able to override it and stop it ready to run another program, the loop just runs endlessly.
I've tried it just with the very simple blink test but once a simple program such as:
digitalWrite(LED_BUILTIN, LOW); Serial.print("LED is BLINK ON\n"); delay(500); digitalWrite(LED_BUILTIN, HIGH); Serial.print("LED is BLINK OFF\n"); delay(500);
has been triggered via the URL, it just runs endlessly (which is what I want), but it cannot be stopped or overridden by a different URL being called.
Any suggestions greatly appreciated.