Added FastLED test
This commit is contained in:
parent
852092e998
commit
b663d5121a
@ -3,19 +3,40 @@
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <FastLED.h>
|
||||
|
||||
// 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<WS2812B, DATA_PIN, RGB>(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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user