#include #include const char* ssid = "Maulwurf"; // Your Wi-Fi Name const char* password = "51663200120302609600"; // Wi-Fi Password int touch = A0; int LEDR = 4; int LEDG = 5; int LEDB = 3; int d = 4; int value; int red; int green; int blue; int res = 2; WiFiServer server(80); void setup() { pinMode(A0, INPUT); Serial.begin(115200); //Default Baudrate pinMode(LEDR, OUTPUT); pinMode(LEDG, OUTPUT); pinMode(LEDB, OUTPUT); pinMode(res, INPUT); digitalWrite(res, HIGH); Serial.print("Connecting to the Newtork"); WiFi.begin(ssid, password); // WiFi.setSleepMode(WIFI_NONE_SLEEP); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("WiFi connected"); server.begin(); // Starts the Server Serial.println("Server started"); Serial.print("IP Address of network: "); // will IP address on Serial Monitor Serial.println(WiFi.localIP()); Serial.print("Copy and paste the following URL: https://"); // Will print IP address in URL format Serial.print(WiFi.localIP()); Serial.println("/"); for (int i = 0; i < 3; i++) { analogWrite(LEDR, 255); analogWrite(LEDG, 255); analogWrite(LEDB, 255); delay(500); analogWrite(LEDR, 0); analogWrite(LEDG, 0); analogWrite(LEDB, 0); delay(500); } } void(*resetFunc)(void) = 0; void loop() { WiFiClient client = server.available(); if (!client) { return; } Serial.println("Waiting for new client"); int counter = 0; while (!client.available()) { delay(1); Serial.println(analogRead(touch)); if (analogRead(touch) > 150) { resetFunc(); } } String request = client.readStringUntil('\r'); Serial.println(request); client.flush(); if (request.indexOf("/LED=ON") != -1) { // On red = 200; green = 1000; blue = 500; } if (request.indexOf("/LED=OFF") != -1) // Off { red = 0; green = 0; blue = 0; } if (request.indexOf("LEDRB") != -1 ) { // red brighter if (red < 1023) { red = red + 100; } } if (request.indexOf("LEDRD") != -1 ) { // red darker if (red > 0) { red = red - 100; } } if (request.indexOf("LEDGB") != -1 ) { // green brighter if (green < 1023) { green = green + 100; } } if (request.indexOf("LEDGD") != -1 ) { // green darker if (green > 0) { green = green - 100; } } if (request.indexOf("LEDBB") != -1 ) { // blue brighter if (blue < 1023) { blue = blue + 100; } } if (request.indexOf("LEDBD") != -1 ) { // blue darker if (blue > 0) { blue = blue - 100; } } if (request.indexOf("LEDRGB") != -1) { int stopper = 0; analogWrite(LEDR, 1023); while (stopper < 150) { stopper = Rainbow(); } delay(500); } if (request.indexOf("LEDRON") != -1) { if (red > 0) { red = 0; } else { red = 1023; } } if (request.indexOf("LEDBON") != -1) { if (blue > 0) { blue = 0; } else { blue = 1023; } } if (request.indexOf("LEDGON") != -1) { if (green > 0) { green = 0; } else { green = 1023; } } analogWrite(LEDG, green); analogWrite(LEDB, blue); analogWrite(LEDR, red); //*------------------HTML Page Code---------------------*// client.println("HTTP/1.1 200 OK"); // client.println("Content-Type: text/html"); client.println(""); client.println(""); client.println(""); client.print(" CONTROL LED: "); client.println("

"); client.println(""); client.println("
"); client.println(""); client.println(""); client.println(""); client.println("
"); client.println(""); client.println(""); client.println(""); client.println("
"); client.println(""); client.println(""); client.println(""); client.println("
"); client.println(""); client.println("
"); client.println(""); delay(1); Serial.println("Client disonnected"); Serial.println(""); } int Rainbow() { for (int z = 0; z < 1023; z++) { analogWrite(LEDG, z); delay(d); if (analogRead(touch) > 150) { return 250; } } for (int y = 1023; y > 0; y--) { analogWrite(LEDR, y); delay(d); if (analogRead(touch) > 150) { return 250; } } for (int y = 0; y < 1023; y++) { analogWrite(LEDB, y); delay(d); if (analogRead(touch) > 150) { return 250; } } for (int z = 1023; z > 0; z--) { analogWrite(LEDG, z); delay(d); if (analogRead(touch) > 150) { return 250; } } for (int z = 0; z < 1023; z++) { analogWrite(LEDR, z); delay(d); if (analogRead(touch) > 150) { return 250; } } for (int z = 1023; z > 0; z--) { analogWrite(LEDB, z); delay(d); if (analogRead(touch) > 150) { return 250; } } if (analogRead(touch) > 150) { return 250; Serial.println("Stopped"); } else { return 0; } }