Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #include <ESP8266WebServer.h>
- ESP8266WebServer server(80);
- void handleRoot()
- {
- // HTML da pagina principal
- String html = "<html><head><title>Exemplo 1</title>";
- html += "<style>body { background-color: #cccccc; ";
- html += "font-family: Arial, Helvetica, Sans-Serif; ";
- html += "Color: #000088; }</style>";
- html += "</head><body>";
- html += "<h1>Exemplo 1</h1>";
- html += "<p>Pagina Principal</p>";
- html += "<p><a href=/updateATMega></a></p>";
- html += "</body></html>";
- // Enviando HTML para o servidor
- server.send(200, "text/html", html);
- }
- void setup()
- {
- // Iniciando Serial
- Serial.begin(115200);
- // Iniciando WiFi
- WiFi.begin("ssid", "pword");
- IPAddress subnet(255, 255, 255, 0);
- WiFi.config(IPAddress(192, 168, 0, 26),
- IPAddress(192, 168, 0, 1), subnet);
- // Aguardando conectar na rede
- Serial.println("");
- while (WiFi.status() != WL_CONNECTED)
- {
- delay(500);
- Serial.print('.');
- }
- // Mostrando IP
- Serial.println("");
- Serial.print("IP address: ");
- Serial.println(WiFi.localIP());
- // Atribuindo urls para funções
- server.on("/", handleRoot);
- // Iniciando servidor
- server.begin();
- // Apenas informando que servidor iniciou
- Serial.println("HTTP server started");
- }
- void loop()
- {
- // No loop só precisa dessa função
- server.handleClient();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement