#include #include #include int DIN = 7; int CS = 6; int CLK = 5; LedControl lc=LedControl(DIN,CLK,CS,0); char ssid[] = "ToniDuje"; char pass[] = "Paulina07"; int keyIndex = 0; int status = WL_IDLE_STATUS; WiFiServer server(80); WiFiClient client = server.available(); int ledPin = 2; void setup() { lc.shutdown(0,false); lc.setIntensity(0,15); lc.clearDisplay(0); Serial.begin(9600); pinMode(ledPin, OUTPUT); while (!Serial); enable_WiFi(); connect_WiFi(); server.begin(); printWifiStatus(); } void loop() { client = server.available(); if (client) { printWEB(); } } void printWifiStatus() { Serial.print("SSID: "); Serial.println(WiFi.SSID()); IPAddress ip = WiFi.localIP(); Serial.print("IP Addressa: "); Serial.println(ip); long rssi = WiFi.RSSI(); Serial.print("Jačina signala (RSSI):"); Serial.print(rssi); Serial.println(" dBm"); Serial.print("Otvorite za nastavak rada: http://"); Serial.println(ip); } void enable_WiFi() { String fv = WiFi.firmwareVersion(); if (fv < "1.0.0") { Serial.println("Molim vas da unaprijedite svoj hardcode."); } } void connect_WiFi() { while (status != WL_CONNECTED) { Serial.print("Pokušaj spajanja na SSID: "); Serial.println(ssid); // korstin WPA status = WiFi.begin(ssid, pass); delay(10000); } } void printWEB() { if (client) { Serial.println("new client"); String currentLine = ""; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); if (c == '\n') { if (currentLine.length() == 0) { client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println(); client.println(); client.println(""); client.println(""); client.println(" Arduino Crtanje2"); client.println(""); client.println(""); client.println("

Crtaj Ovdje!

"); client.println("
"); client.println("
"); client.println("
"); client.println("
"); client.println("
"); client.println("
"); client.println("
"); client.println("
"); client.println("
"); client.println("
"); client.println(""); client.println(); break; } else { currentLine = ""; } } else if (c != '\r') { currentLine += c; } if (currentLine.endsWith("/buttonR")) { lc.clearDisplay(0); } if (currentLine.endsWith("/button1")) { lc.setLed(0,0,0,true); } if (currentLine.endsWith("/button2")) { lc.setLed(0,0,1,true); } if (currentLine.endsWith("/button3")) { lc.setLed(0,0,2,true); } if (currentLine.endsWith("/button4")) { lc.setLed(0,0,3,true); } if (currentLine.endsWith("/button5")) { lc.setLed(0,0,4,true); } if (currentLine.endsWith("/button6")) { lc.setLed(0,0,5,true); } if (currentLine.endsWith("/button7")) { lc.setLed(0,0,6,true); } if (currentLine.endsWith("/button8")) { lc.setLed(0,0,7,true); } if (currentLine.endsWith("/button9")) { lc.setLed(0,1,0,true); } if (currentLine.endsWith("/button10")) { lc.setLed(0,1,1,true); } if (currentLine.endsWith("/button11")) { lc.setLed(0,1,2,true); } if (currentLine.endsWith("/button12")) { lc.setLed(0,1,3,true); } if (currentLine.endsWith("/button13")) { lc.setLed(0,1,4,true); } if (currentLine.endsWith("/button14")) { lc.setLed(0,1,5,true); } if (currentLine.endsWith("/button15")) { lc.setLed(0,1,6,true); } if (currentLine.endsWith("/button16")) { lc.setLed(0,1,7,true); } if (currentLine.endsWith("/button17")) { lc.setLed(0,2,0,true); } if (currentLine.endsWith("/button18")) { lc.setLed(0,2,1,true); } if (currentLine.endsWith("/button19")) { lc.setLed(0,2,2,true); } if (currentLine.endsWith("/button20")) { lc.setLed(0,2,3,true); } if (currentLine.endsWith("/button21")) { lc.setLed(0,2,4,true); } if (currentLine.endsWith("/button22")) { lc.setLed(0,2,5,true); } if (currentLine.endsWith("/button23")) { lc.setLed(0,2,6,true); } if (currentLine.endsWith("/button24")) { lc.setLed(0,2,7,true); } if (currentLine.endsWith("/button25")) { lc.setLed(0,3,0,true); } if (currentLine.endsWith("/button26")) { lc.setLed(0,3,1,true); } if (currentLine.endsWith("/button27")) { lc.setLed(0,3,2,true); } if (currentLine.endsWith("/button28")) { lc.setLed(0,3,3,true); } if (currentLine.endsWith("/button29")) { lc.setLed(0,3,4,true); } if (currentLine.endsWith("/button30")) { lc.setLed(0,3,5,true); } if (currentLine.endsWith("/button31")) { lc.setLed(0,3,6,true); } if (currentLine.endsWith("/button32")) { lc.setLed(0,3,7,true); } if (currentLine.endsWith("/button33")) { lc.setLed(0,4,0,true); } if (currentLine.endsWith("/button34")) { lc.setLed(0,4,1,true); } if (currentLine.endsWith("/button35")) { lc.setLed(0,4,2,true); } if (currentLine.endsWith("/button36")) { lc.setLed(0,4,3,true); } if (currentLine.endsWith("/button37")) { lc.setLed(0,4,4,true); } if (currentLine.endsWith("/button38")) { lc.setLed(0,4,5,true); } if (currentLine.endsWith("/button39")) { lc.setLed(0,4,6,true); } if (currentLine.endsWith("/button40")) { lc.setLed(0,4,7,true); } if (currentLine.endsWith("/button41")) { lc.setLed(0,5,0,true); } if (currentLine.endsWith("/button42")) { lc.setLed(0,5,1,true); } if (currentLine.endsWith("/button43")) { lc.setLed(0,5,2,true); } if (currentLine.endsWith("/button44")) { lc.setLed(0,5,3,true); } if (currentLine.endsWith("/button45")) { lc.setLed(0,5,4,true); } if (currentLine.endsWith("/button46")) { lc.setLed(0,5,5,true); } if (currentLine.endsWith("/button47")) { lc.setLed(0,5,6,true); } if (currentLine.endsWith("/button48")) { lc.setLed(0,5,7,true); } if (currentLine.endsWith("/button49")) { lc.setLed(0,6,0,true); } if (currentLine.endsWith("/button50")) { lc.setLed(0,6,1,true); } if (currentLine.endsWith("/button51")) { lc.setLed(0,6,2,true); } if (currentLine.endsWith("/button52")) { lc.setLed(0,6,3,true); } if (currentLine.endsWith("/button53")) { lc.setLed(0,6,4,true); } if (currentLine.endsWith("/button54")) { lc.setLed(0,6,5,true); } if (currentLine.endsWith("/button55")) { lc.setLed(0,6,6,true); } if (currentLine.endsWith("/button56")) { lc.setLed(0,6,7,true); } if (currentLine.endsWith("/button57")) { lc.setLed(0,7,0,true); } if (currentLine.endsWith("/button58")) { lc.setLed(0,7,1,true); } if (currentLine.endsWith("/button59")) { lc.setLed(0,7,2,true); } if (currentLine.endsWith("/button60")) { lc.setLed(0,7,3,true); } if (currentLine.endsWith("/button61")) { lc.setLed(0,7,4,true); } if (currentLine.endsWith("/button62")) { lc.setLed(0,7,5,true); } if (currentLine.endsWith("/button63")) { lc.setLed(0,7,6,true); } if (currentLine.endsWith("/button64")) { lc.setLed(0,7,7,true); } } } // close the connection: client.stop(); Serial.println("client disconnected"); } }