diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2018-07-19 15:20:46 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2018-07-19 15:20:46 +0200 |
commit | f95e6a8b0fbd4b2af4a1a5d78d0f75c0265aa8d0 (patch) | |
tree | 7038424c4500581fce9903c98d6c46e445d60f1a /Luxcena-cs.ino | |
parent | 8afb6934e01d3560203f53cc0fb4e0b975801467 (diff) | |
download | Luxcena-cs-master.tar.gz Luxcena-cs-master.zip |
Diffstat (limited to 'Luxcena-cs.ino')
-rw-r--r-- | Luxcena-cs.ino | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Luxcena-cs.ino b/Luxcena-cs.ino index 41bef63..16bad53 100644 --- a/Luxcena-cs.ino +++ b/Luxcena-cs.ino @@ -1,6 +1,7 @@ #include <ESP8266WiFi.h> #include <WiFiClient.h> #include <ESP8266WebServer.h> +#include <ESP8266HTTPUpdateServer.h> #include <ESP8266mDNS.h> #include <FS.h> #include <EEPROM.h> @@ -46,6 +47,7 @@ int sensorthreshold = 600; int bufferKey[6] = {0, 0, 1, 0, 1, 0}; ESP8266WebServer server ( 80 ); // webServer on port 80 +ESP8266HTTPUpdateServer httpUpdater; void setup ( void ) { // Activate serial @@ -134,10 +136,12 @@ void setup ( void ) { Serial.println(myIP); } - if ( MDNS.begin ( "esp8266" ) ) { + if ( MDNS.begin ( "clapSensor" ) ) { Serial.println ( "MDNS responder started" ); } + httpUpdater.setup(&server); + // Gui server.on ( "/", handleRoot ); server.on ( "/settings", handleSettings ); @@ -178,17 +182,20 @@ void loop ( void ) { eventStatus = 0; sensorValue = analogRead(A0); + //Serial.println(sensorValue); delay(1); if (eventStatus == 0) { if (sensorValue > sensorThresholdHigh) { + Serial.println("Level up: 1"); eventStatus = 1; } } - if (eventStatus == 0) { + if (eventStatus == 1) { for (int i = 0; i > 10; i++) { sensorValue = analogRead(A0); if(sensorValue < sensorthresholdLow) { + Serial.println("Level up: 2"); eventStatus = 2; break; } @@ -199,12 +206,14 @@ void loop ( void ) { sensorValue = analogRead(A0); delay(1); if (sensorValue > sensorThresholdHigh) { + Serial.println("Level up: 3"); eventStatus = 3; break; } } } if (eventStatus == 3) { + Serial.println("TOGGLE!!!!!!"); setLamp("TOGGLE"); } |