forked from magnusbae/esp8266
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathardu.ino
More file actions
32 lines (26 loc) · 729 Bytes
/
ardu.ino
File metadata and controls
32 lines (26 loc) · 729 Bytes
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
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WiFiClient.h>
const char *ssid = "ESP8266";
const char *password = "";
const int ledPin = D4;
ESP8266WebServer server(80);
int state = LOW;
void toggleLED() {
state = state == HIGH ? LOW : HIGH;
digitalWrite(ledPin, state);
server.send(200, "text/plain", "PIN " + String(ledPin) + " is now " + String(state));
}
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, state);
Serial.println("WIFI SSID is " + String(ssid));
WiFi.softAP(ssid, password);
server.on("/", toggleLED);
server.begin();
Serial.println("IP is " + String(WiFi.softAPIP()));
}
void loop() {
server.handleClient();
}