Advertisement
Jaturapad

lab-Go-Internet3

Sep 1st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2. #include <ESP8266WebServer.h>
  3.  
  4. const char* ssid = "OBEC27";  // Access point name
  5. const char* password = "12345678";  // Access point password
  6. ESP8266WebServer server(80);
  7.  
  8.  
  9. void setup() {
  10.   Serial.begin(9600);
  11.  
  12.   // Connect to WiFi network
  13.   Serial.println();
  14.   Serial.print("Connecting to ");
  15.   Serial.println(ssid);
  16.  
  17.   WiFi.begin(ssid, password);
  18.  
  19.   while (WiFi.status() != WL_CONNECTED) {
  20.     delay(500);
  21.     Serial.print(".");
  22.   }
  23.   Serial.println("");
  24.   Serial.println("WiFi connected");
  25.  
  26.   // Print the IP address
  27.   Serial.println(WiFi.localIP());
  28.   server.on("/", displayHomePage);
  29.   server.on("/form", displayForm);
  30.   server.begin();
  31.   Serial.println("HTTP server started!");
  32. }
  33.  
  34. void loop() {
  35.   server.handleClient();
  36.   }
  37. void displayHomePage(){
  38.   server.send(200, "text/html", "<h1>Hello. Welcome to my Home</h1>");
  39. }
  40. void displayForm(){
  41.   server.send(200, "text/html", "<html><form><button> Press Me! </button></form></html>");
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement