This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:iot-open:espressif_es8266_http_led_control [2023/10/10 08:26] – ktokarz | en:iot-open:espressif_es8266_http_led_control [2023/11/23 10:46] (current) – pczekalski | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Controlling LED with Simple Web Server ====== | ||
+ | {{: | ||
+ | A sample Web application hosted on ESP8266 MCU is presented below.\\ | ||
+ | This application allows it to control the state of the LED remotely, connecting to the ESP8266 board with a web browser. The program presented is based on the example " | ||
+ | |||
+ | Assuming the address in the terminal is '' | ||
< | < | ||
+ | http:// | ||
+ | http:// | ||
+ | </ | ||
+ | |||
+ | <code c> | ||
#include < | #include < | ||
Line 20: | Line 31: | ||
void handleRoot() { | void handleRoot() { | ||
// | // | ||
- | //so we had to comment | + | //so it is required |
// | // | ||
server.send(200, | server.send(200, | ||
Line 27: | Line 38: | ||
void handleNotFound() { | void handleNotFound() { | ||
- | digitalWrite(led, | + | |
String message = "File Not Found\n\n"; | String message = "File Not Found\n\n"; | ||
message += "URI: "; | message += "URI: "; | ||
Line 40: | Line 51: | ||
} | } | ||
server.send(404, | server.send(404, | ||
- | digitalWrite(led, | + | |
} | } | ||
void setup(void) { | void setup(void) { | ||
pinMode(led, | pinMode(led, | ||
- | digitalWrite(led, | + | |
Serial.begin(115200); | Serial.begin(115200); | ||
WiFi.mode(WIFI_STA); | WiFi.mode(WIFI_STA); |