Created
April 29, 2015 05:42
-
-
Save prasertsakd/1726d127f1c8d0ad5318 to your computer and use it in GitHub Desktop.
webserver ap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
#include <WiFiClient.h> | |
#include <ESP8266WebServer.h> | |
const char* ssid = "..............."; | |
const char* password = "..............."; | |
ESP8266WebServer server(80); | |
const int led = 16; | |
void handle_root() { | |
digitalWrite(led, 1); | |
server.send(200, "text/plain", "hello from esp8266!"); | |
delay(100); | |
digitalWrite(led, 0); | |
} | |
void setup(void) | |
{ | |
Serial.begin(115200); | |
pinMode(led, OUTPUT); | |
digitalWrite(led, 0); | |
// Connect to WiFi network | |
WiFi.mode(WIFI_AP); | |
//WiFi.begin(ssid, password); | |
Serial.println(""); | |
// Wait for connection | |
//while (WiFi.status() != WL_CONNECTED) { | |
// delay(500); | |
// Serial.print("."); | |
//} | |
Serial.println(""); | |
//Serial.print("Connected to "); | |
//Serial.println(ssid); | |
Serial.print("IP address: "); | |
Serial.println(WiFi.softAPIP()); | |
server.on("/", handle_root); | |
server.on("/inline", [](){ | |
server.send(200, "text/plain", "this works as well"); | |
}); | |
server.begin(); | |
Serial.println("HTTP server started"); | |
} | |
void loop(void) | |
{ | |
server.handleClient(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment