diff --git a/lichterKette.ino b/lichterKette.ino index d8dbee2..4949fa6 100644 --- a/lichterKette.ino +++ b/lichterKette.ino @@ -1,17 +1,21 @@ #include #ifdef __AVR__ - #include +#include #endif -//Important: Set the number of LEDs here!!! -#define PIN 6 -#define NUMPIXELS 22 +#define PIN D6 +#define NUMPIXELS 28 +Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); -//Create the object representation of our strip -Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); +#include +#include +#include -//Some usefull variables and buffers, currently not all in use -unsigned long previousMillis = 0; +const byte DNS_PORT = 53; +IPAddress apIP(192, 168, 1, 1); +DNSServer dnsServer; +ESP8266WebServer webServer(80); +unsigned long previousMillis = 0; unsigned long interval = 0; int mode = 0; int element = 0; @@ -20,34 +24,272 @@ int colorval1 = 0; int colorval2 = 0; int colorval3 = 0; +String responseHTML = "" + "LedControl" + "

Control


" + "on

off" + "
run
run single
freaky" + "
0
" + "1
" + "2
" + "3
" + "4
" + "5
"; + +void handleOn() { + mode = 0; + for (int i = 0; i < NUMPIXELS; i++) { + strip.setPixelColor(i, strip.Color(200, 50, 0)); // Moderately bright green color. + } + strip.show(); + webServer.send(200, "text/html", responseHTML); +} + +void handle1() { + mode = 1; + Serial.println("LOL"); + webServer.send(200, "text/html", responseHTML); +} + +void handle2() { + mode = 2; + Serial.println("LOL2"); + webServer.send(200, "text/html", responseHTML); +} +void handle3() { + mode = 3; + Serial.println("LOL3"); + webServer.send(200, "text/html", responseHTML); +} + + + +void handleOff() { + mode = 0; + for (int i = 0; i < NUMPIXELS; i++) { + strip.setPixelColor(i, strip.Color(0, 0, 0)); // off + } + strip.show(); + webServer.send(200, "text/html", responseHTML); +} +void handleShow() { +Serial.println(webServer.args()); +} void setup() { - pixels.begin(); + strip.begin(); + Serial.begin(115200); + + WiFi.mode(WIFI_AP); + WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); + WiFi.softAP("Scary?"); + + // if DNSServer is started with "*" for domain name, it will reply with + // provided IP to all DNS request + dnsServer.start(DNS_PORT, "*", apIP); + + webServer.on("/on", handleOn); + webServer.on("/off", handleOff); + + webServer.on("/show", handleShow); + + + webServer.on("/1", handle1); + webServer.on("/2", handle2); + webServer.on("/3", handle3); + + + webServer.onNotFound([]() { + webServer.send(200, "text/html", responseHTML); + }); + + webServer.begin(); + } void loop() { + dnsServer.processNextRequest(); + webServer.handleClient(); - if(element= interval) { + // save the last time you blinked the LED + previousMillis = millis(); + + switch(mode){ + + case 1: + interval = 100; + if(element 150) colorval2=0; + if(colorval1 < 30) colorval2=1; + for(int i=0;i