Hi,
I am looking to build upon a current project which controls the D1 Mini V4 RGB shield in a preset color pattern. I have the code working for this fine using a simple sketch with delay for various color changes. I went with a KISS (Keep It Simple Sketch) even though I know most people don't like using delay function it works perfectly for what I wanted at the time.
Now what I am trying to do is make it so the code can be altered or an alternative light show selected.
I've managed to get the onboard LED to work via a simple sketch using it as a WiFi Access Point and a simple HTML On/Off code (see code below) which I assembled from a few different public codes for WiFiAP control of the onboard LED.
I have a few different ideas of how I could do this, but I'm not sure if any of them are actually feasible with this hardware.
Idea 1 - create a custom light show on the WiFi access point HTML page, save it and others as options and save 1 as the default program when it turns on. [I'm not sure if this would work because of the saving to the D1 Mini even after power is shut off as well as the processor can only process either the light show THEN the selection via WiFiAP. Perhaps if I add a button and have 15 sec after the device is powered up to push the button to access the WiFiAP before it switches to the light show??]
Idea 2 - create an similar code to below, but instead of simple On/Off, have various pre-set light shows that would be selected every time from the WiFiAP HTML page. [Downside of this would be having to connect the phone to the WiFiAP every time in order to start the show]
Idea 3 - write an app that would do above, but connect it all the time [Not sure how I could do this as I believe ESP8266 doesn't have bluetooth]. The D1 mini is at my workplace and therefore probably would not be approved to hook up to our network in any fashion
Idea 4 - last resort would be to use a different chip (I think there is a D1 mini on ESP32 but I'd have to look into it more) that has bluetooth and write an app. The light show would still have to be selected from the app, but I think using bluetooth would make this much less arduous. I'm hoping to avoid this as I really like the D1 mini V4 size and RGB shield.
Anyone have any comments, ideas, concerns?
TIA
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
// Replace with your network credentials
const char* ssid = "Testwifi";
const char* password = "WifiTest1";
ESP8266WebServer server(80); //instantiate server at port 80 (http port)
void setup (void) {
//the HTML of the web page;
String index = "<h1>Simple NodeMCU Web Server</h1><p><a href=\"LEDOn\"><button>ON</button></a> <a href=\"LEDOff\"><button>OFF</button></a></p>";
//make the LED pin output and initially turned off
//192.168.4.1
pinMode(D4, OUTPUT);
digitalWrite(D4, LOW);
delay(1000);
Serial.begin(115200);
WiFi.softAP(ssid, password); //begin WiFi access point
Serial.println("");
server.on("/", [index]() {
server.send(200, "text/html", index);
});
server.on("/LEDOn", [index]() {
server.send(200, "text/html", index);
digitalWrite(D4, LOW);
delay(1000);
});
server.on("/LEDOff", [index]() {
server.send(200, "text/html", index);
digitalWrite(D4, HIGH);
delay(1000);
});
server.begin();
Serial.println("Web server started!");
}
void loop(void) {
server.handleClient();
}