-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.ino
43 lines (33 loc) · 988 Bytes
/
main.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
// Set web server port number to 80
ESP8266WebServer server(80);
// Set BUILTIN LED
const int ledPin = BUILTIN_LED;
// Network credentials
const char *ssid = "PSP-CONTROLLER SERVER";
const char *password = "";
void setup() {
// Initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
// Start Serial
Serial.begin(115200);
delay(10);
// Configure as an access point
Serial.println();
Serial.println("Setting up WiFi AP...");
WiFi.softAP(ssid, password);
IPAddress IP = WiFi.softAPIP();
// web server routes
server.on("/on", []() { digitalWrite(ledPin, LOW); server.send(200, "text/html", ""); });
server.on("/off", []() { digitalWrite(ledPin, HIGH); server.send(200, "text/html", ""); });
// Start the server
server.begin();
Serial.print("HTTP server started: ");
Serial.println(IP);
}
void loop() {
// Handle client requests
server.handleClient();
}