From b663d5121a62e6ce102aa2c4e0e408a317a522c3 Mon Sep 17 00:00:00 2001 From: agreiner Date: Mon, 12 Apr 2021 23:31:40 +0200 Subject: [PATCH] Added FastLED test --- WEBSERVER_LED_CONTROL.ino | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/WEBSERVER_LED_CONTROL.ino b/WEBSERVER_LED_CONTROL.ino index 77b37a1..60b747b 100644 --- a/WEBSERVER_LED_CONTROL.ino +++ b/WEBSERVER_LED_CONTROL.ino @@ -3,19 +3,40 @@ #include #include #include +#include +// LED count and control pin +#define NUM_LEDS 8 +#define DATA_PIN D3 + +// LED array +CRGB leds[NUM_LEDS]; + +// Web server ESP8266WebServer server(80); + + void setup() { + // Initialize onboard LED + pinMode(LED_BUILTIN, OUTPUT); + // Initialize Wifi, start AP if no saved Wifi in range WiFiManager wifiManager; wifiManager.autoConnect("WEMOS D1 mini pro"); + // Initialize LEDs + FastLED.addLeds(leds, NUM_LEDS); + + // Define web server Handlers server.on("/", handleRoot); server.onNotFound(handleNotFound); + // Start webserver server.begin(); + + } void loop() { @@ -28,4 +49,21 @@ void handleRoot() { void handleNotFound() { server.send(404, "text/plain", "404 File Not Found"); + blinkLEDs(); +} + +void blinkLEDs(){ + digitalWrite(LED_BUILTIN, LOW); + for(int i=0;i<8;i++){ + leds[i] = CRGB::Red; + FastLED.show(); + delay(20); + } + delay(500); + for(int i=0;i<8;i++){ + leds[i] = CRGB::Black; + FastLED.show(); + delay(20); + } + digitalWrite(LED_BUILTIN, HIGH); }